Hi guys, I have a Windows PC at work which keeps changing its default printer. I know how to change the default printer using powershell, but I'd like it to sit in the background and everytime it changes, change it back. I'm guessing this is really simple, but it's too early for my brain right now
This is rather quick but seems to work: Code: #Set printer name $printerName = "\\server.domain.com\printer-name" #can be got from $printers below #Get the infos of all printer $Printers = Get-WmiObject -Class Win32_Printer Write-Verbose "Get the specified printer info." $Printer = $Printers | Where{$_.Name -eq "$PrinterName"} If($Printer) { Write-Verbose "Setting the default printer." $Printer.SetDefaultPrinter() | Out-Null Write-Host "Successfully set the default printer." } Else { Write-Warning "Cannot find the specified printer." }
I did this at work this week as part of an installer, I used: (New-Object -ComObject WScript.Network).SetDefaultPrinter('PRINTER NAME IN HERE') Is running as a task an option for you? Maybe triggered from an event log entry for a change of default printer? I'm not sure if there is a logging option for default printer changes mind so just a thought. Just wondering, this PC at work isn't Windows 10 is it? The Windows 10 option to manage default printer has just been disabled globally at my place as it was causing issues where we install things such as PDF viewers etc stealing being the default and we like the mono printers to be default
Doesn't Windows 10 also have an option where it automatically changes the default printer to the last printer used? IIRC, this is turned on by default (it's in Settings->Devices->Let Windows manage my default printer)