Link to home
Start Free TrialLog in
Avatar of mjm21
mjm21Flag for United States of America

asked on

Powershell / Quest Commandlets Script to get all printers in the domain

Powershell / Quest Commandlets Script for all printers in the domain.  Would like to list all network printers in the domain and export to .csv file.
Avatar of piattnd
piattnd

Give the following command a try, though it is listed as being a command for Server 2012 and Windows 8.

Get-Printer -ComputerName SERVERNAME | ? published

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mjm21

ASKER

Ok - thanks will test in a few....
Avatar of mjm21

ASKER

Getting Error:  Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty an
d then try the command again.
At line:4 char:49
+ Get-WmiObject -Class Win32_Printer -ComputerName <<<<  $Printer.Server | Select SystemName, ShareName, Name, Location | Export-csv "c:\exportedPri
nters.csv" }
    + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetWmiObjectCommand
That error above is due to the CSV file it is reading. Make sure that it has the appropriate name structure.

You can test this with one individual computer name see below...

Get-WmiObject -Class Win32_Printer -ComputerName <namehere> | Select SystemName, ShareName, Name, Location | Export-csv "c:\exportedPrinter.csv

Will.
Avatar of mjm21

ASKER

I have tested with single name with above script worked....but something wrong with this:

 -ComputerName $Printer.Server
You need to make sure that your CSV file is constructed like I have illustrated above. In column A you need Server as the heading and all of the server names below. I have tested this in my environment and it works.

Will.
Avatar of mjm21

ASKER

Yes - that's was the problem.  Did not put server in the heading.  Many thanks!