Get Printer Details From Multiple Servers

Recently it was necessary for me to catalogue some printer details accross a number of servers. The requested information was the printer’s name, driver, port IP address and the server name. I was able to write a PowerShell script fairly quickly for this and then run it against multiple computers with the help of Invoke-Command. I’ll break it down here. Full script at the bottom.

Collecting the printer details

The first step, obviously is to collect all of the printers, or the subset that you need.

$printers = Get-Printer

Then we’re going to loop through the printers and get the port and other details that we require.

Run it against multiple servers

That will work fine the way it is, but we want to run the script against multiple servers. The simplest way to achieve this is to use the Invoke-Command cmdlet.
We can feed it a set of servers inline, from a variable, or using another cmdlet like Get-ADComputer, if you have Active Directory.

Now, I deliberately haven’t stored the server name in the object yet. That’s because when we used Invoke-Command,
the returned objects automatically get a property called PSComputerName, and we can just use that in the output.