检测到公共语言运行时程序和无效程序 [英] Common Language Runtime detected and invalid program

查看:353
本文介绍了检测到公共语言运行时程序和无效程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


执行代码时出现此错误。 my  powershell  版本
是  5.1
vs version是2017


这里我的代码。感谢您的帮助。这里我的代码

here my codes. thanks for any help. here my codes

static void Main(string [] args)
{

var script = @"
$ ous ='OU =测试,DC =测试,DC =本地'
$当=((获取日期).AddDays(-20))。日期
$ ous | ForEach {Get-ADUser -Filter {whenCreated -ge $ When} -Properties whenCreated,* -SearchBase $ _}
" ;;

var powerShell = PowerShell.Create();
powerShell.AddScript(script);

foreach(var Office in powerShell.Invoke())
{
Console.WriteLine(Office);
}
}

static void Main(string[] args) { var script = @" $ous = 'OU=test,DC=test,DC=local' $When = ((Get-Date).AddDays(-20)).Date $ous | ForEach { Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated,* -SearchBase $_ } "; var powerShell = PowerShell.Create(); powerShell.AddScript(script); foreach (var Office in powerShell.Invoke()) { Console.WriteLine(Office); } }


https://eksiup.com/e5da346d7307

https://eksiup.com/e5da346d7307

推荐答案

嗨  CarteL1st,

Hi CarteL1st,

感谢您在此发帖。

对于您的问题,我测试了代码。我的电脑上没有错误。请检查您的参考。

For your question, I test the code. There is no error on my PC. Please check your reference.

我从C:\Program Files(x86)\ Reference Assemblies\Microsoft \ WindowsPowerShell \ 3.0添加  System.Management.Automation.dll。

I add the System.Management.Automation.dll from C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0.

最诚挚的问候,

Wendy


这篇关于检测到公共语言运行时程序和无效程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆