Programming + ScriptingPowershell Swap default printers using Powershell Script Updated August 11 2024
Copy to Clipboard $Printers = Get-CimInstance -Class Win32_Printer $DefaultPrinter = "" $Printer1 = "RICOH MP C6004" $Printer2 = "HP LaserJet 600" foreach ( $Printer in $Printers ){ if ( $Printer.Default ){ $DefaultPrinter = $Printer.Name } } write-Host "Old Default printer: $($DefaultPrinter)" if ( $DefaultPrinter -match $Printer1 ){ $NewPrinter = $Printer2 }else{ $NewPrinter = $Printer1 } foreach ( $Printer in $Printers ){ if ( $Printer.Name -match $NewPrinter ){ Invoke-CimMethod -InputObject $Printer -MethodName SetDefaultPrinter | Out-Null } } # Check for new printer $Printers = Get-CimInstance -Class Win32_Printer foreach ( $Printer in $Printers ){ if ( $Printer.Default ){ $DefaultPrinter = $Printer.Name } } write-Host "New Default printer: $($DefaultPrinter)"




©2024 - Some portions of this website are Copyrighted.
Your IP: 3.137.176.213     Referring URL:
Browser: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Terms and Conditions, Privacy Policy, and Security Policy