title: Error setting default printer via Get-WmiObject: Exception calling SetDefaultPrinter : Not Supported
body: <h1>Overview</h1>
  
  <p>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. </p>
  
  <h1>Error</h1>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <h1>Code Example</h1>
  
  <h2>Works when run locally</h2>
  
  <pre><code>$Printer = Get-WmiObject -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')"
  $Printer.SetDefaultPrinter()
  </code></pre>
  
  <h2>Fails when run remotely</h2>
  
  <pre><code>$Printer = Get-WmiObject -ComputerName "MyRemoteComputer" -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')"
  $Printer.SetDefaultPrinter()
  </code></pre>
  
  <h2>Also fails when run remotely</h2>
  
  <pre><code>Invoke-Command -ComputerName "MyRemoteComputer" -ScriptBlock {(Get-WmiObject -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')").SetDefaultPrinter()}
  </code></pre>
  
  <h2>Third failure attempt</h2>
  
  <pre><code>Get-WmiObject -ComputerName "MyRemoteComputer" -Class Win32_Printer -Filter "(Name='Microsoft XPS Document Writer')" | Invoke-WmiMethod -Name 'SetDefaultPrinter'
  </code></pre>
  
  <p>Any help and guidance greatly appreciated.</p>