Windows – Find Printer Name from IP address

network-printershared-printers

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.

Best Answer

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!