title: Get default printer remotely
body: <p>Windows 7: </p>
  
  <pre><code>cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g
  </code></pre>
  
  <p>Windows XP:</p>
  
  <pre><code>cscript C:\windows\system32\prnmngr.vbs -g
  </code></pre>
  
  <p>These will get the default printer of the current system. I was wondering if there is a way to run this on my computer to get the default printer of a remote computer by computer name?</p>
  
  <p>I tried running: </p>
  
  <pre><code>psexec \\c78572 -i -d cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g
  </code></pre>
  
  <p>And it appears to run.. but I only see the results in a quick popup cmd line window on the remote computer and not on mine. All I see on my end is:</p>
  
  <pre><code>cscript started with process ID 568.
  </code></pre>
  
  <p>In powershell <code>gwmi win32_printer -computername c78572</code> works.. but I don't know how to sort it to show me the default printer.</p>
  
  <p>EDIT 12/20/13 I am trying to combine it with a show all printers and the default but I can't get it to work:</p>
  
  <pre><code>while (1) {
  $tag1 = Read-Host 'Enter tag # or Q to quit'
  if ($tag1 -eq "Q") {
      break;
  }
  
  cls
  
  sc.exe \\$tag1 start RemoteRegistry;
  
  cls
  
  start-sleep -seconds 2
  
  cls
  
  $OSInfo = get-wmiobject -class win32_operatingsystem -computername $tag1;
  $OSInfo | Format-Table -Property @{Name="OS Name";Expression={$_.Caption}},@{Name="System Boot Time";Expression={$_.ConvertToDateTime($_.LastBootUpTime)}} -AutoSize;
  
  
  gwmi win32_printer -computername $tag1 | ft -Property @{Name="Printer Name";Expression={$_.Name}} -AutoSize;
  
  $Computer = $tag1
  $Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('currentuser', $Computer)
  $RegKey= $Reg.OpenSubKey('Software\Microsoft\Windows NT\CurrentVersion\Windows')
  $DefaultPrinter = $RegKey.GetValue("Device")
  $DefaultPrinter | ConvertFrom-Csv -Header Name, Provider, Order| Select Name
  
  # Alt method: Get-WmiObject win32_printer -computername c60311
  </code></pre>
  
  <p>}</p>