如何在 PowerShell 中从 Invoke-Command 输出中排除 RunSpaceID 属性?
powershellmicrosoft technologiessoftware & coding
在 PowerShell 中编写 Invoke-Command 时,有时会在 PowerShell 中获取 RunSpaceID 属性。这是因为我们在脚本块中使用了 Select-Object(别名:Select)命令。例如:
示例
Invoke-Command -ComputerName LabMachine2k12 -ScriptBlock{Get-Process PowerShell | Select Name, CPU, WorkingSet}
输出
Name : powershell CPU : 9.1572587 WorkingSet : 127700992 PSComputerName : LabMachine2k12 RunspaceId : c690f205-06d4-4cc4-be29-5302725eadf1
为避免在输出中获取 RunSpaceID 属性,请使用 Select 命令输出脚本块。例如:
示例
Invoke-Command -ComputerName LabMachine2k12 -ScriptBlock{Get-Process PowerShell} | Select Name, CPU, WorkingSet
输出
Name CPU WorkingSet ---- --- ---------- powershell 9.1572587 127700992
相关文章
打印
下一节:如何在 PowerShell 中将命令输出转换为哈希表格式? ❯❮ 上一节:如何在 PowerShell 中从 Invoke-Command 输出中排除 PSComputerName 属性?

