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.
I try this, but my variable just comes up blank. Any ideas? Thanks in advance.
$gottenUserName = (Get-WmiObject -ComputerName $thaTargetHost -Namespace root\cimv2 -Class Win32_ComputerSystem)[0].UserName;