Wednesday, September 22, 2010

Powershell - Setting default printer in the Desktop

In Windows 7 setting a default printer through powershell cmdlets is a easier task when compared to VBscript. It can achieved through fewer commands. The commands and their description are given below

CMDLETS

$Printer = Get-WmiObject win32_printer  | where {$_.name -match "XPS"}
$Printer.SetDefaultPrinter()

"XPS" in the command can be replaced by your printer name , unique word which will exactly point your printer can be mentioned within the quotations  

win32_Printer 

This WMI class will hold all the printer information in your computer

SetDefaultPrinter() 

This method inside Win32_Printer will set the selected printer as a default printer



No comments: