How do I include computername in output

烂漫一生 提交于 2019-12-11 08:48:21

问题


PS newbe here...

How do I get the remote computer name to appear in the output?

$computer = "PC3090-121","APCD02" 
Get-WmiObject Win32_Printer -ComputerName $computer |
  Select-Object SystemName,Name,Local |
  Format-Table -AutoSize

I've tried including -computername, computername, %computername% in the Select and format-table -properties - no joy...

My searches have come up empty, or I couldn't understand them.

------------------------------ answer:

$computer = "PC3090-121","APCD02" 
Get-WmiObject Win32_Printer -ComputerName $computer |
  Select-Object  __Server, Name, Local |
  Format-Table -AutoSize

回答1:


How about simply

Get-WmiObject Win32_Printer -ComputerName $computer |
  Select-Object SystemName,Name,Local |
  Format-Table -AutoSize

There is no computername property on the resulting object, nor is there a %computername% property. What exists is SystemName.



来源:https://stackoverflow.com/questions/18640660/how-do-i-include-computername-in-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!