• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3585
  • Last Modified:

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.
0
mjm21
Asked:
mjm21
  • 4
  • 3
1 Solution
 
piattndCommented:
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

0
 
Will SzymkowskiSenior Solution ArchitectCommented:
You can accomplish this by using the following command below...

For the below script to work you will need to get a list of all print servers and put it into a CSV file. The format should be like below...

Server
PrintServer1
PrintServer2
etc...

$Printers = import-csv "c:\youCSVhere.csv"
foreach ($Printer in $Printers) {
$Printer.Server
Get-WmiObject -Class Win32_Printer -ComputerName $Printer.Server | Select SystemName, ShareName, Name, Location | Export-csv "c:\exportedPrinters.csv
}

Open in new window


Results will be in a CSV file called ExportedPrinters.csv

Will.
0
 
mjm21Author Commented:
Ok - thanks will test in a few....
0
On-Demand: Securing Your Wi-Fi for Summer Travel

Traveling this summer?Check out our on-demand webinar to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

 
mjm21Author Commented:
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
0
 
Will SzymkowskiSenior Solution ArchitectCommented:
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.
0
 
mjm21Author Commented:
I have tested with single name with above script worked....but something wrong with this:

 -ComputerName $Printer.Server
0
 
Will SzymkowskiSenior Solution ArchitectCommented:
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.
0
 
mjm21Author Commented:
Yes - that's was the problem.  Did not put server in the heading.  Many thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now