简体   繁体   English

调用命令并添加计算机名称列

[英]Invoke-Command and add computer name column

How can I add some computername column like PSComputerName ? 如何添加PSComputerName类的computername列?

Invoke-Command -ComputerName $cpu {
  Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | 
    Where-Object {$_.DisplayName -like "app"} |  
    Select-Object PSComputerName, DisplayName, DisplayVersion, Publisher, InstallDate |
    Format-Table PSComputerName, DisplayName, DisplayVersion, Publisher, InstallDate
} -ErrorAction SilentlyContinue | Out-File $logFile

The registry key you're reading doesn't have a value PSComputerName . 您正在读取的注册表项没有值PSComputerName You can add it with a calculated property , though: 不过,您可以添加带有计算属性的属性

Select-Object @{n='PSComputerName';e={$env:COMPUTERNAME}}, DisplayName, ...

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

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