Overview
I'm attempting to use PowerShell to set a default printer in Windows 2012 R2. This works fine every time whenever I do it locally, however regardless of how I attempt to run it remotely, which I need to do, it always fails with the below error. I've tried this with the Domain Administrator account as well as the user's credentials who I need to change the default printer for, but it still fails.
Error
Exception calling "SetDefaultPrinter" : "Not supported " At line:1 char:1 + (Get-WmiObject -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Write ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WMIMethodException
Code Example
Works when run locally
$Printer = Get-WmiObject -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')"
$Printer.SetDefaultPrinter()
Fails when run remotely
$Printer = Get-WmiObject -ComputerName "MyRemoteComputer" -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')"
$Printer.SetDefaultPrinter()
Also fails when run remotely
Invoke-Command -ComputerName "MyRemoteComputer" -ScriptBlock {(Get-WmiObject -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')").SetDefaultPrinter()}
Third failure attempt
Get-WmiObject -ComputerName "MyRemoteComputer" -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')" | Invoke-WmiMethod -Name 'SetDefaultPrinter'
Any help and guidance greatly appreciated.