简体   繁体   English

使用 C# 运行 PowerShell 脚本

[英]Using C# to run a PowerShell script

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

Is that right?那正确吗?
What's the next step?下一步是什么?

From MSDN :来自MSDN

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

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

var results = powershell.Invoke();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM