Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having issues listing all the printers on a computer using Powershell.

We have a batch script that will add/remove/list "per computer" printers using PrintUI.

I can use PrintUI to list the printers.

    rundll32 printui.dll,PrintUIEntry /ge /c"%UNC-NAME%"

This will list just the per computer printers, while...

    Get-WMIObject -Class Win32_Printer -ComputerName $ComputerName

will list the all printers in WMI.

In the above example I have a system that has 3 printers, when a user is logged in. WMI see's 2 of them, PrintUI see's 1.

I'm boggled how I can list them ALL! So that I can script auditing/adding/removing both "per computer" and "local" printers

share|improve this question
2  
Do you mean "both 'per computer' and 'per user' printers"? Users may add their own printers in addition to the per-computer ones. Do you need to iterate all user profiles on the computer, or just the current active profile? – jscott Aug 22 '12 at 2:01
    
I know I can't see "per user" printers, but I'm looking for all printers that ALL users would see on a computer. "per computer" and "local" Ideally, I would be running this remotely, so my tech does not have to go to each computer to add/remove printers. If a user adds their own to their profile, I don't care. But I want to make sure we can see what printers are available within one view. – Schlauge Aug 22 '12 at 14:27
    
In your scenario what is the difference between "local" and "per computer"? – Mike Aug 24 '12 at 12:30
    
A "Local" printer is a printer assigned to a local port. This might be LPT: or even a TCP-IP port (still network, but directly from PC->Printer). A "per computer" printer is printing through another computer's printer spooler \\PrintSpooler\P23S If the user connect directly to \\PrintSpooler\P23S this is "per user" If I use rundll32 printui.dll,PrintUIEntry /ga /c\\PCName /n\\PrintSpooler\P23S It will make the network printer available for all users who login to PCNAME – Schlauge Aug 25 '12 at 1:00
    
I want the same list as the user get in printing menu. (....) – MUY Belgium Jul 22 '15 at 7:26

get-shared printers

Get-Printer -ComputerName pc| where Shared -eq $true | fl Name

get not shared printers

 Get-Printer -ComputerName pc | where Shared -eq $false | fl Name

get mapped printers

Get-WMIObject Win32_Printer -ComputerName $env:COMPUTERNAME | where{$_.Name -like “*\\*”} | select sharename,name

get all the printers

Get-WMIObject Win32_Printer -ComputerName $env:COMPUTERNAME
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.