1

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 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

4 Comments

SystemName returns the name of the host for the printer/print service. If the remote PC uses a print server the name of the print server host is returned.
__SERVER then, maybe. Otherwise you could just wrap a loop around the call: foreach ($c in $computer) { gwmi Win32_printer -computername $c | select @{l='ComputerName';e={$c}},Name,Local } or something like that.
You can inspect objects with all their properties (and values) by using Format-List -Force * or (fl -fo *). This is often helpful in finding which properties you need to select.
@Joey can we use $Env:ComputerName variable?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.