3

Trying to find the Printer Queue name with IP address. Printer is hosted on a Server.

  • Searched in AD for the IP - but no luck.
  • nbtstat returned the device name, but it does not exist in the AD.

I know for sure the printer exist in the network on a print server. We have about 40-50 print servers.

Any help appreciated.

hanes
  • 84
  • 1
  • 1
  • 4
  • How do you know there is only one printer at that IP? It's very common to have a single print server hosting numerous printers. Which name do you choose? – Joel Coel Jan 16 '13 at 17:47
  • Ah... I see you mean the IP of the printer. It sounded to me at first like you had the IP of the server and wanted to know which printer was there. But this is just as tricky... a single printer could easily be shared from more than one place. For example, the college I work for has a different print server for students than for staff/faculty, but they both expose a lot of the same printers. – Joel Coel Jan 16 '13 at 17:48

1 Answers1

4

You have the IP address of the printer itself (for management or for direct printing) and want to know what Windows print server it is being shared out on? Is that correct?

You can "manually" search each print server (which I figure would be easier than querying all of them since I figure you would probably have some idea logically of where it might reside, such as narrowing it down to 5 print servers that are local to the subnet the printer is on).

Using Powershell (where $printservername is the likely print server hostname):

Get-WMIObject -class Win32_Printer -computer $printservername | Select Name,DriverName,PortName | Where-Object {$_.PortName -eq "IP_x.x.x.x"}

Note that you might go ahead and run it without the Where-Object portion to see what the PortName output looks like but it should be similar to IP_10.10.10.10 or similar.

If you don't get any results, then that print server isn't the one hosting that IP address.


UPDATE: since you wanted a input file, I went ahead and did that for you as well. You'll need 2 input files, one with the list of print servers and one with the IP address listed or the IP_x.x.x.x listed. Please realize that if you use something else for your port names such as hostname/DNS you'll need to put those into your printerIP.txt file as such. If you don't know the exact PortName then this script won't return any result. Also, only put one "portname" in the printerIP.txt or it will not return any matching result.

# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Script: Find-WhichPrintServer.ps1
# Author: TheCleaner, serverfault.com
# Date: 1/16/2013
# Comments: This script will query each of the computers in the input file and look for a particular printer's IP address on that print server.  If found it will output the name of the print server and printer name and info
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$printservers = Get-Content -Path C:\PSinput\PrintServers.txt
$printerIP = Get-Content -Path C:\PSinput\printerIP.txt #note this must be the correct format such as IP_x.x.x.x
Get-WMIObject -class Win32_Printer -computer $printservers | Select SystemName,Name,DriverName,PortName | Where-Object {$_.PortName -eq $printerIP} |
Format-Table -Property SystemName, PortName, Name, DriverName -AutoSize

Hope that helps!

TheCleaner
  • 32,352
  • 26
  • 126
  • 188
  • TheCleaner, thanks for your response! Waiting to collect all the print server hostnames, so I can do a get-content from a text file and run the cmdlet. Thanks again. Will update. – hanes Jan 16 '13 at 16:31
  • I've updated the answer with a get-content cmdlet. – TheCleaner Jan 16 '13 at 18:07
  • Did this work ok for you? I haven't been able to properly get it to work with multiple IP addresses yet, so just curious. – TheCleaner Jan 17 '13 at 20:53