Solved

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

Posted on 2013-12-16
8
3,307 Views
Last Modified: 2013-12-17
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
Comment
Question by:mjm21
  • 4
  • 3
8 Comments
 
LVL 12

Expert Comment

by:piattnd
ID: 39722035
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
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
ID: 39722156
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
 

Author Comment

by:mjm21
ID: 39722343
Ok - thanks will test in a few....
0
 

Author Comment

by:mjm21
ID: 39722505
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
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39722521
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
 

Author Comment

by:mjm21
ID: 39722676
I have tested with single name with above script worked....but something wrong with this:

 -ComputerName $Printer.Server
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39722815
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
 

Author Comment

by:mjm21
ID: 39723931
Yes - that's was the problem.  Did not put server in the heading.  Many thanks!
0

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now