Quantcast
Viewing latest article 2
Browse Latest Browse All 28

Getting a list of printers published in an Active Directory domain

Image may be NSFW.
Clik here to view.
c2800c5000printers-thumb.jpg

So I need to get a list of print servers and printers in the domain.

Using Powershell.

Looking around the interwebs, I found a PowerShell commandline here which formed the basis of this commandline:
Get-ADObject -LDAPFilter "(objectCategory=printQueue)" -Properties cn, drivername, location, printername, portname, servername | select portname, cn, drivername, location, printername, servername | Format-Table -Property * -AutoSize | Out-String -Width 4096 | Out-File C:\wisefaq\printerlist.txt

Which outputs to a text file, like this:
portname cn drivername location printername servername
-------- -- ---------- -------- ----------- ----------
{101.112.138.188} PRT001-APPLELWR001 APPLE LASERWRITER II US/UT/Boort/10 Anytown St APPLELWR001 PRT001.noddyland.com
{112.142.229.22} PRT001-LZR960-2 Dataproducts LZR 960 PS US/UT/Boort/99 Anytown St LZR960-2 PRT001.noddyland.com
{101.192.107.56} PRT001-LZR960-1 Dataproducts LZR 960 PS US/UT/Boort/99 Anytown St LZR960-1 PRT001.noddyland.com
{101.192.107.56} PRT001-LZR960-3 Dataproducts LZR 960 PCL US/UT/Boort/99 Anytown St LZR960-3 PRT001.noddyland.com
{101.46.14.220} PRT001-LZR960-4 Dataproducts LZR 960 PS US/UT/Boort/99 Anytown St LZR960-4 PRT001.noddyland.com
{101.46.14.220} PRT001-LZR960-5 Dataproducts LZR 960 PCL US/UT/Boort/99 Anytown St LZR960-5 PRT001.noddyland.com

So why did I use Out-File instead of Export-CSV?
Export-CSV is refusing to output the {ip.addresses}. I don’t know why, and I’ve wasted an hour trying to work around the issue.

References:
PowerShell Quick Tip: Creating wide tables with PowerShell

Searching for Specific Printers in a Domain (Attributes for the printQueue Object)

Print-Queue class

PowerShell print server inventory script (looks very useful, but you need admin access to each of the printers)


Viewing latest article 2
Browse Latest Browse All 28

Trending Articles