?
Solved

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

Posted on 2013-12-16
8
Medium Priority
?
3,518 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 2000 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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 

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

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

750 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