How do I include computername in output

2019-07-31 09:26发布

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条回答
放荡不羁爱自由
2楼-- · 2019-07-31 09:50

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.

查看更多
登录 后发表回答