使用C#运行PowerShell脚本

时间:2011-07-22 18:08:15

标签: c# powershell

PowerShell powershell = PowerShell.Create();
PSCommand command = new PSCommand();
command.AddScript("[System.Net.ServicePointManager]::ServerCertificateValidationCallback+={$true}");

是吗?
下一步是什么?

1 个答案:

答案 0 :(得分:6)

来自MSDN

PSCommand command = new PSCommand(); 
command.AddScript( 
    "[System.Net.ServicePointManager]::ServerCertificateValidationCallback+={$true}"
); 

PowerShell powershell = PowerShell.Create();
powershell.Commands = cmd;

var results = powershell.Invoke();