I want to run following PS cmd using C#
Get-SCRunAsAccount -VMMServer VmmserverName -Name proName | Remove-SCRunAsAccount
I have tried below program but profile is not getting deleted. When i run the above cmd in Powershell it worked, which mean no issue with cmd. but not sure why Object of RunAsAccount is not passing over pipeline in C#.
also i have tried run Get-process | Sort-Object VM
Get-process | Sort-Object VM
using pipeline in c# it worked.
help me what i am missing here
Pipeline pipeline = Runspace.CreatePipeline();
Collection<PSObject> results = null;
string output = null;
Command command = new Command("Get-SCRunAsAccount");
command.Parameters.Add("VMMServer", "VmmserverName");
command.Parameters.Add("Name", "proName");
Command command1 = new Command("Remove-SCRunAsAccount");
pipeline.Commands.Add(command);
pipeline.Commands.Add(command1);
pipeline.Commands.Add("Out-String");
results = pipeline.Invoke();
您需要先导入SCVMM
cmdlet,然后才能使用它们:
pipeline.Commands.Add("Import-Module").AddParameter("Name","VirtualMachineManager");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.