title: Powershell - Get Logged in User on Remote Host and Store Username as Variable
body: <p>Trying to use a Get-WmiObject to get the currently or last logged in username on a remote pc, then store that value to a variable so I can later use it as part of a path.</p>
  
  <p>I try this, but my variable just comes up blank.  Any ideas?  Thanks in advance.</p>
  
  <pre><code>$gottenUserName = (Get-WmiObject -ComputerName $thaTargetHost -Namespace root\cimv2 -Class Win32_ComputerSystem)[0].UserName;
  </code></pre>