The job of System Administrators are very adventurous, sometime you have to find a little-little settings and sometime you have to write a big-big, hundred’s of line’s scripts.
Today, my task was to find a default printer installed on laptops. To solve it , i used the Win32_Printer class.
You can run the below query on your laptop and this will show you the default installed printer on your system.
To run the below command on the remote system you can –Computer parameter and make sure you are proper admin rights to access the system.
We are using Get-WmiObject cmdlet and then we are running a WQL query to select everything from Win32_Printer class and choose to show that result where default value is true.
Get-WmiObject -Query ” SELECT * FROM Win32_Printer WHERE Default=$true”
If you want to see all printers installed on your laptop, you can run the below code and this will show you the list of all printers, with their Port Name and location.
Get-WmiObject -Query ” SELECT * FROM Win32_Printer” | Select Name, Default, PortName,Location
I love WMI .
Happy learning . ;o) .
Tested on : Windows7 [64 bit]