# ip address to get printer property

**URL:** <https://forums.powershell.org/t/ip-address-to-get-printer-property/14391>\
**Category:** PowerShell Help\
**Created:** [May 19, 2020, 12:29pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391 "2020-05-19T12:29:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbarreiro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jbarreiro](https://forums.powershell.org/u/jbarreiro)\
**Post date:** [May 19, 2020, 12:29pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/1 "2020-05-19T12:29:22Z")

</div>

Hi ,

New here and to PowerShell .

Was looking to get help with an issue. We have a few printers on the network and was trying to get status on them via ipaddress .

I had tried this

$pn = $null  
$pn = Get-Content “.\printersnoton.txt”  
$allprinters = @()  
foreach( $pn in $pn ){  
Write-Host “checking $Printer …”  
$printer = $null  
$printers = $null  
$printers = Get-Printer -name {$_. $pn}  
$printer = $printers | where-object {$_.shared}  
#| select-object sharename, DriverName, PortName, SystemName, Location | Export-CSV .\printers3.csv  
$allprinters += $printer  
}  
Write-Host “exporting to printers3.csv”  
$allprinters | select-object name, DriverName, PortName, Location, Printerstaus | Export-CSV .\printers3.csv -NoTypeInformation  
Write-Host “Done!”

but get into trouble over the ip address …any help will be appreciated.

Thanks John B

&nbsp;

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 19, 2020, 1:15pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/2 "2020-05-19T13:15:45Z")

</div>

jbarreiro81, welcome to [Powershell.org](http://Powershell.org). Please take a moment and read the very first post on top of the list of this forum: [Read Me Before Posting! You’ll be Glad You Did!](https://powershell.org/forums/topic/read-me-before-posting-youll-be-glad-you-did).

When you post code, error messages, sample data or console output format it as code, please.  
In the “Text” view you can use the code tags “PRE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.  
Thanks in advance.

Let’s start with exactly what you’re trying to accomplish with the code posted. You have a list of printer names. You want to get all printers (assume a print server) and then get the details of the printers in the list? Take a look at this simplified code:

```
#List of printer names
$pn = Get-Content “.\printersnoton.txt”
#Assuming this is run on a print server with all printers
$allPrinters = Get-Printer
#Get all of the printers in the printer list
$printersInList = $allPrinters | Where{$pn -contains $_.Name}
```

Next you want the IP of the printer, that should be in the PortName, but let’s start with the basics of what you are trying to do above and then talk about the IP Address.

---

<div class="post-metadata">

**Author:** ![jbarreiro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jbarreiro](https://forums.powershell.org/u/jbarreiro)\
**Post date:** [May 19, 2020, 1:35pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/3 "2020-05-19T13:35:53Z")

</div>

Oops

&nbsp;

$pn = $null  
$pn = Get-Content “.\printersnoton.txt”  
$allprinters = @()  
foreach( $pn in $pn ){  
Write-Host “checking $Printer …”  
$printer = $null  
$printers = $null  
$printers = Get-Printer -name {$_. $pn}  
$printer = $printers | where-object {$_.shared}

# select-object sharename, DriverName, PortName, SystemName, Location | Export-CSV .\printers3.csv

$allprinters += $printer  
}  
Write-Host “exporting to printers3.csv”  
$allprinters | select-object name, DriverName, PortName, Location, Printerstaus | Export-CSV .\printers3.csv -NoTypeInformation  
Write-Host “Done!”

How does that look?

Any way trying to get info for printers not on a printserver.

In the printersnoton.txt file is a list of ip addresses . I fI look for the printer name it never find it because it is not local to my machine.

Thanks

John B.

---

<div class="post-metadata">

**Author:** ![jbarreiro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jbarreiro](https://forums.powershell.org/u/jbarreiro)\
**Post date:** [May 19, 2020, 2:18pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/4 "2020-05-19T14:18:14Z")

</div>

Oops I have done it wrong again …  
This is what I use for getting info from print servers …

`$servers = Get-Content “.\server-list.txt”  
$allprinters = @()  
foreach( $server in $servers ){  
Write-Host “checking $server …”  
$printer = $null  
$printers = $null  
$printers = Get-Printer -computername $server  
$printer = $printers | where-object {$\_.shared}  
#| select-object sharename, DriverName, PortName, Location, printerstatus | Export-CSV .\process.csv  
$allprinters += $printer  
}  
Write-Host “exporting to printers.csv”  
$allprinters | select-object sharename, DriverName, PortName, Location, printerstatus | Export-CSV .\printers.csv -NoTypeInformation  
Write-Host “Done!”

again sorry for that hope this comes out ok!

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 19, 2020, 2:36pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/5 "2020-05-19T14:36:38Z")

</div>

Still incorrect on the code, please re-read the instructions. You have a printer IP address, that according the the naming is not working? The printer is installed on the system where Get-Printer is being run? If you look at the PortName (or other column), do you see the IP address you’re searching for? If I wanted to find something, you would see how you can filter. Below you list Name and PortName and then find something that has the number in it:

```
PS C:\Users\rasim> Get-Printer | Select Name, PortName

Name PortName                                                                                                                          
---- --------                                                                                                                          
Send To OneNote nul:                                                                                                                              
Snagit 2020 C:\ProgramData\TechSmith\Snagit 20\PrinterPortFile                                                                                
OneNote for Windows 10 Microsoft.Office.OneNote_16001.12730.20190.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-2370741873-3768727752-2996739931-1001
Microsoft XPS Document Writer PORTPROMPT:                                                                                                                       
Microsoft Print to PDF PORTPROMPT:                                                                                                                       
Fax SHRFAX:                                                                                                                           
Canon TS9100 series WSD-e189f362-50bd-44e0-9539-ba4820a552c0                                                                                          

PS C:\Users\rasim> Get-Printer | Where{$_.PortName -like '*01.12730.20190*'}

Name ComputerName Type DriverName PortName Shared Published DeviceType     
---- ------------ ---- ---------- -------- ------ --------- ----------     
OneNote for Windows 10 Local Microsoft Software Pri... Microsoft.Of... False False Print
```

Try to find one IP in the PortName and then we can look at how to search with a list

---

<div class="post-metadata">

**Author:** ![jbarreiro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jbarreiro](https://forums.powershell.org/u/jbarreiro)\
**Post date:** [May 20, 2020, 7:04am UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/6 "2020-05-20T07:04:21Z")

</div>

Thanks Rob but maybe using the wrong command? The printers are at another location and are used by 2 or 3 people there.  
So they are on the network but not on a printserver , sort of stand alone . My point is that maybe get-printer is not what I should be using  
since that network is no a different segment . I also did not want to add it to my PC so I can then get the status and info I was trying to get.  
Thanks for all your help not used to sending out and looking for help elsewhere… sorry for not knowing what to do but just started trying powershell. I also have not been trained…

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [May 20, 2020, 7:50am UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/7 "2020-05-20T07:50:45Z")

</div>

If you’re trying to query the printers directly, perhaps you should look at SNMP? Are you not able to query the printers via one of the computers there that have it installed? Even though they may not be “servers,” they can still act like a print server.

---

<div class="post-metadata">

**Author:** ![jbarreiro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jbarreiro](https://forums.powershell.org/u/jbarreiro)\
**Post date:** [May 20, 2020, 7:56am UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/8 "2020-05-20T07:56:45Z")

</div>

Was trying not to go to the other computers to get the info . Trying to get it directly from printers. I will look into SNMP though.  
Thanks for the input.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 20, 2020, 8:55am UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/9 "2020-05-20T08:55:53Z")

</div>

If they are standalone printers and all you have is an IP, there isn’t much you can do outside of a simple ping to see if the IP is responding. A list of IP’s like so:

**printersnoton.txt**

```
8.8.8.8
9.9.9.9
10.10.123.123
```

YOu can check status with Test-Connection:

```
#List of printer names
$pn = Get-Content “.\printersnoton.txt”
$pn | Select @{Name='IP';Expression={$_}}, @{Name='Online';Expression={Test-Connection -ComputerName $_ -BufferSize 16 -Count 1 -Quiet}}
```

**Output:**

```
IP Online
-- ------
8.8.8.8 True
9.9.9.9 True
10.10.123.123 False
```

---

<div class="post-metadata">

**Author:** ![jbarreiro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jbarreiro](https://forums.powershell.org/u/jbarreiro)\
**Post date:** [May 20, 2020, 9:46am UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/10 "2020-05-20T09:46:35Z")

</div>

Thanks Rob ,  
So there is nothing I can use to pass the ip address to so that I can view info ….  
tried other things that ask for computer name , but would not respond to the printer name such as ADG HP 610 ….  
OK at least I can find out if it is online…

Thanks for your help greatly appreciate it.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 20, 2020, 10:00am UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/11 "2020-05-20T10:00:09Z")

</div>

The Printers aren’t running a Windows OS. Most of the printer validation scripts are executed on a Windows server acting as a print server hosting queues, which is where Get-Printer or WMI Win32\_Printer is applicable. This is normal in corporate environments accessing a queue \prtsrv1\Bldg2ColorPtr or something like that. If the printer has an IP address just assigned to a network card and it is being accessed by IP on the end points by installing a driver only, then the printer needs to be queried by management software by the manufacturer which is going to use SNMP as Doug eluded above.

---

<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:29pm UTC](https://forums.powershell.org/t/ip-address-to-get-printer-property/14391/12 "2024-05-16T20:29:40Z")

</div>

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


