返回自定义对象

时间:2015-10-26 08:48:42

标签: c# powershell

script += string.Format(@"$Processes = Get-Process -ComputerName {0} | Sort-Object CPU -desc | Select-Object;", remoteMachineName);
script += @"$ProcessArray= @();";
script += @"foreach ($process in $Processes) {";
script += @"$ProcessNamesss = $process.ProcessName;";
script += @"$objAverage = New-Object System.Object;";
script += @"$objAverage | Add-Member -type NoteProperty -name Name -value $ProcessNamesss;";
script += @"$ProcessArray +=$objAverage; } ";
script += "$ProcessArray;";

我的代码运行正常。但它返回109结果。它应该返回包含109个对象的数组的一个结果?我已填写foreach循环? 我怎样才能只返回那个数组$ProcessArray

0 个答案:

没有答案