List ALL Printers using Powershell
Solution 1:
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
Solution 2:
For some strange reason these commands can't see printers mapped in a per user context. As found in a different question, the following code will scan the registry for all user accounts and all list printers for all users.
List all printers for all users.
NOTE: Requires WinRM
param (
[string]$Comp = "localhost"
)
function ListAllPrinters {
param (
[string]$Comp
)
Invoke-Command -ComputerName $Comp -ScriptBlock {
Get-ChildItem Registry::\HKEY_Users |
Where-Object { $_.PSChildName -NotMatch ".DEFAULT|S-1-5-18|S-1-5-19|S-1-5-20|_Classes" } |
Select-Object -ExpandProperty PSChildName |
ForEach-Object { Get-ChildItem Registry::\HKEY_Users\$_\Printers\Connections -Recurse | Select-Object -ExpandProperty Name }
}
}
# Main
ListAllPrinters $Comp