我準備調用powershell腳本並通過參數。我都希望最終通過一個以上的參數使用C#將變量賦值給powershell
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
runspace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
Pipeline pipeline = runspace.CreatePipeline();
String scriptfile = "..\\..\\Resources\\new group.ps1";
Command myCommand = new Command(scriptfile, false);
CommandParameter testParam = new CommandParameter("test3");
myCommand.Parameters.Add(testParam);
pipeline.Commands.Add(myCommand);
Collection<PSObject> psObjects;
psObjects = pipeline.Invoke();
runspace.Close();
這個問題似乎是......沒有任何反應。這是如何正確分配變量?給予測試PowerShell腳本
# creates group
net localgroup $username /Add
# makes folder
#mkdir $path
不回答你的問題這麼多的快速評論 - 您是否試圖通過.NET與本地ADSI商店進行交互? http://stackoverflow.com/questions/1640022/adsi-library-control-for-net – 2012-08-07 16:13:13
沒有從來沒有經歷過的,但由於 – 2012-08-07 16:18:13