Currently I'm working on creating a PS script to scan a network and retrieve all of the Windows Servers, their product keys, SQL Server product keys, CPU, RAM, Network Shares and Services on all the Windows servers found. Basically this is to compile a list of information for site-evaluations before merging networks into ours when our company purchases a new office/other company. So far I've been able to get all of this part working fairly neatly, with the information being pushed to .txt or .csv files.

The only other major part missing from the information I want to gather is network printers. So far the closest thing I can find is a method to return the uPNP devices on the network, which does not return all of the printers. The only ones it's returning currently are Ricoh MFPs and we also have a mix of HP and other printers on the network as well.

My question is if there is a method or a function within Powershell to retrieve the IP, Make and Model of printers on a network? Currently the script takes the users input for a network to scan in the form of X.X.X.0 and retrieves information on a per-IP basis (via a loop and counter) up to X.X.X.254 so if the method/cmdlet is IP/host specific that is fine.

I've not found anything for retrieving printers' info using PS other than getting local printers or printers off of a print server and most of the companies we deal with do not have print servers.

Thanks ahead of time.

  • 1
    I'm with mfinni, as I'm unaware of a PS script that does this for straight IP printers, most look for printers shared via a Windows print server. Spiceworks like others will use SNMP or scraping the HTTP page of the printer as it scans. You could consider running nmap or similar scans against these subnets (again as Spiceworks also does). I would personally also recommend that in addition to a scan, you do a physical inventory walk through to make sure everything lines up. – TheCleaner Mar 6 '14 at 22:31
  • We do a physical inventory walkthrough it's just helpful to have the reports, and trying to save time finding this information. I do agree Spiceworks would do this but we have limited time on-site and don't have time to set up Spiceworks and wait for the network scans to complete. I've looked and can't find how to do it with Powershell and wanted to see if perhaps someone knew something I didn't. I appreciate the suggestions. – Mike Naylor Mar 7 '14 at 2:25
  • This is thoroughly unanswerable in its current form, least of all because there's no guarantee your network printers will respond on any given port. Without physically locating each printer, you're left scanning every IP on 65535 ports. What you're looking for here is a proper port scanning utility, not a PowerShell script. – HopelessN00b Mar 7 '14 at 3:18
  • @hopelessn00b, not necessarily. I just got a script working to scan port 9100 for responses which is a standard printer port. Its not unanswerable, its a "yes and here is a way/method" or "no not with powershell. – Mike Naylor Mar 7 '14 at 3:28
  • 1
    @MikeNaylor Fine. "No, not with PowerShell. For the exact same reasons I don't screw in screws with a hammer." – HopelessN00b Mar 7 '14 at 3:40

So to half-way solve the issue I found a method to check for responses on port 9100, which is used by most network printers, and output the IP list to a Printers.csv file. This will act as a reference to fill in printer addresses manually later. Some of the methods used were extracted from this article in case anyone else wishes to reference it. I changed the port to 9100 and set an IF statement to push IPs into an array while looping through the network, then push the array to the .csv.

So far this has worked on Ricoh, HP and Konica printers in our environment. Hope this helps anyone else who may be working with Powershell to create a quick scanning script.


Here is a copy of the .ps1 file I've made so far in case anyone else is working on a similar project. It doesn't return ESX server names or printer makes and models but at least puts the IPs in a CSV so you know where to start looking.

| improve this answer | |
  • Does that actually answer with make and model? I don't have many to test against. The laserjet near me doesn't answer with anything. If you simply wanted a PS script to determine the presence of printers and didn't care about make and model then yes, that's going to be a lot easier. Not 100% guaranteed, but will work for most cases. – mfinni Mar 7 '14 at 20:53
  • This doesnt give make and model but is currently all i can get. I also did the same scan on port 902 for VMware esx hosts as that is the heartbeat port. This at least gives me a start for the initial info gathering and shows me where to look for things. Not 100% but much quicker than a walkaround/logon party, and faster than spiceworks. – Mike Naylor Mar 7 '14 at 21:08
  • 1
    As @thecleaner said, NMap will do those for you and quickly. You can specify ports that you care about, or just accept its common ones. It has built in OS detection which is usually a decent start. – mfinni Mar 7 '14 at 21:26
  • Im using powershell because I can also pull the Windows and SQL product keys for licensing reports as well. – Mike Naylor Mar 7 '14 at 21:45
  • Well yes of course, NMap won't do that. That doesn't mean you can't use more than one tool. – mfinni Mar 7 '14 at 21:50

I'm going to answer your question with a different method of getting what you want, not a way to do it the way you're asking.

Have you looked into Spiceworks? It does a bang-up job of gathering all (or at least most) of that info and a lot more, and it's free. I work for a consulting firm that does IT assessments for small companies, and we use it to get a really good first-pass of their entire inventory.

They've already put the time into figuring out the hooks of most vendor devices to get this info. If you do it yourself from scratch, you have to know how each printer vendor configured the HTML for their management pages (and there could be multiple product lines per vendor) and you'd have to scrape that. You're going to have to build a database of all printer vendors and product lines, with the way to query the product info for each of them - if it's via SNMP, or telnet, or scraping a HTTP(S) page. Spiceworks will already do that for you.

I'm a big fan of doing something cool and interesting, but I'm a bigger fan of not re-inventing wheels, especially if I'm not selling wheels, I'm driving people around.

| improve this answer | |
  • We've used spiceworks before it's just the setup/config time on that vs running a script is substantial. I need something modular to walk into an office, scan it and get the info I need. Also the scan time on the script I have is less than 15 minutes. Last time I used Spiceworks it took much longer for the scan to complete. – Mike Naylor Mar 6 '14 at 21:08
  • Let us know how you approach this printer-identification issue. Do you have models from each vendor to test against? An Okidata will present its info very differently from an HP. – mfinni Mar 6 '14 at 21:11
  • We currently have Konica, HP, and Ricohs in the office I'm based out of. There is an old OkiData in the back but I'm not sure that it's networked. So far the only success I've had is scanning a PC and getting it's mapped printers but that is not a good way of finding ALL the devices. I thought about MAC address ID'ing the printers but HP and Dell make printers, desktops, servers and storage.... I'm hoping to find something simple to just get the IP, Make and Model without a lot of fuss. – Mike Naylor Mar 6 '14 at 21:13
  • My point is that there is no such thing, if you're writing it from scratch. You're going to have to build a database of all printer vendors and product lines, with the way to query the product info for each of them - if it's via SNMP, or telnet, or scraping a HTTP(S) page. A company like Spiceworks has already done the work (and maintains it.) – mfinni Mar 6 '14 at 21:21
  • and my point is with the frequency we'd use this, setting up spiceworks is more time consuming and we don't always have the resources to do this. a script can be run on any machine with Powershell. I appreciate the suggestion but it's not what I'm looking for. – Mike Naylor Mar 6 '14 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.