Reputation: 487
I have an issue on a PC with Windows 7 Professional. I need to list the network printers in my local network, I tried to run the list object classes in PowerShell with the command:
Get-WMIObject -List | where {$_.name -match 'win32_printer'}
This shows empty, any suggestion to fix this problem?
EDIT: My script for get the network printers is this:
Set-Location -Path C:\; get-WmiObject -class Win32_printer | ConvertTo-Json | Set-Content -Encoding utf8 C:\\xampp\\htdocs\\project\\view\\data\\printers.json
I need to list the printers in a json file, In my PC runs well, but in the PC where i need to run this script fail
Upvotes: 0
Views: 1500
Reputation: 10044
Your command list out all WMI classes then filters those classes showing all of them that contain Win32_Printer
. It seems that you want use:
Get-WMIObject Win32_Printer
This will list all printers that are connected to your computer (Not all of them that are on your network). Note that it will only show network printer connected to your user account.
If you are looking for all printers on your network you could list all of the queues published in Active Directory
Get-ADObject -Filter "ObjectCategory -eq 'printQueue'"
Note: This command requires the AD module from RSAT
Upvotes: 1