# Get-Printer question

**URL:** <https://forums.powershell.org/t/get-printer-question/9856>\
**Category:** PowerShell Help\
**Created:** [December 13, 2017, 10:18pm UTC](https://forums.powershell.org/t/get-printer-question/9856 "2017-12-13T22:18:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![plewis](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@plewis](https://forums.powershell.org/u/plewis)\
**Post date:** [December 13, 2017, 10:18pm UTC](https://forums.powershell.org/t/get-printer-question/9856/1 "2017-12-13T22:18:26Z")

</div>

Hi All,  
I am relatively new to Powershell. I am trying to write a script that will give me all printers with errors in their print queues. In addition I need to pull them from multiple servers. So far I have the following:

get-printer -computername “servername1”, “servername2”, “servername3”  
| where printerstatus -eq Error | Format-list Name, Jobcount

I keep getting an error related to the -computername parameter. No matter what I try with multiple server entries it does not work. It DOES work with a single server entry.

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![johnnyfive](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@johnnyfive](https://forums.powershell.org/u/johnnyfive)\
**Post date:** [December 14, 2017, 12:21am UTC](https://forums.powershell.org/t/get-printer-question/9856/2 "2017-12-14T00:21:43Z")

</div>

Running ‘Get-Help Get-Printer -Full’ will show you that the ComputerName parameter only accepts one string.  
You will need to create a foreach loop and pass the computers in one at a time.

```
$computerName = "servername1", "servername2", "servername3"

foreach ($computer in $computerName) {

    Get-Printer -ComputerName $computer | where printerstatus -eq Error | Format-list Name, Jobcount
}
```

---

<div class="post-metadata">

**Author:** ![plewis](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@plewis](https://forums.powershell.org/u/plewis)\
**Post date:** [December 14, 2017, 12:43am UTC](https://forums.powershell.org/t/get-printer-question/9856/3 "2017-12-14T00:43:43Z")

</div>

Thank You MUCH John! I notice there is no object for servername with Get-Printer. Do you know of a way to pull in the servername for each printer’s output?

---

<div class="post-metadata">

**Author:** ![johnnyfive](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@johnnyfive](https://forums.powershell.org/u/johnnyfive)\
**Post date:** [December 14, 2017, 12:52am UTC](https://forums.powershell.org/t/get-printer-question/9856/4 "2017-12-14T00:52:14Z")

</div>

Using your example, if you are just looking for the computer name to be part of the output you just need to add the ComputerName property to Format-List.

```
$computerName = "servername1", "servername2", "servername3"

foreach ($computer in $computerName) {

    Get-Printer -ComputerName $computer | where printerstatus -eq Error | Format-list ComputerName, Name, Jobcount
}
```

---

<div class="post-metadata">

**Author:** ![plewis](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@plewis](https://forums.powershell.org/u/plewis)\
**Post date:** [December 14, 2017, 1:09am UTC](https://forums.powershell.org/t/get-printer-question/9856/5 "2017-12-14T01:09:21Z")

</div>

Thank You! Very much Appreciate it John! Enjoying learning Powershell and am extremely grateful for the support of the community!

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [December 14, 2017, 10:01am UTC](https://forums.powershell.org/t/get-printer-question/9856/6 "2017-12-14T10:01:05Z")

</div>

Get-Printer can accept a collection of CimSessions so you could do something like

$cs = New-CimSession -ComputerName “servername1”, “servername2”, “servername3”  
Get-Printer -CimSession $cs

You could even possibly do

Get-Printer -CimSession “servername1”, “servername2”, “servername3”

As CimSession will often take list of computer names and automatically create and dispose of the sessions

---

<div class="post-metadata">

**Author:** ![plewis](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@plewis](https://forums.powershell.org/u/plewis)\
**Post date:** [December 14, 2017, 7:48pm UTC](https://forums.powershell.org/t/get-printer-question/9856/7 "2017-12-14T19:48:51Z")

</div>

Thanks Richard!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:36pm UTC](https://forums.powershell.org/t/get-printer-question/9856/8 "2024-05-16T20:36:59Z")

</div>

Closed on May 16, 2024, 8:36pm UTC


