Find print servers in Active Directory from the command line

Run the following on a machine that has the AD DS Snap-ins and Command-Line tools installed (or appropriate on older OS, e.g. AdminPak on Windows XP):

for /f "delims=, tokens=2" %i in ('dsquery * dc^=your^,dc^=active^,dc^=directory -filter "(objectCategory=printQueue)" -limit 0') do @echo %i

Replace dc^=your^,dc^=active^,dc^=directory with your AD info, remembering to escape (prefix with a ^) all the = and , symbols.

This searches Active Directory for printQueue objects, then gives you the CN of the machine that the printer is on.

There will be duplicates, so if you have a print server with 100 printers on it you’ll see it listed 100 times. Dump the data into Excel and do a “Remove Duplicates” (on the Data ribbon).

This entry was posted in Scripting and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.