Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Win32_ComputerSystem and UserName

$
0
0

I have this code:

$machine='AnyPC'
$computerSystem=Get-WMIObject-class Win32_ComputerSystem -ComputerName$machine
$computerName=$computerSystem.name
$model=$computerSystem.model
$LoggedUser=$computerSystem.UserName
$LoggedUser

Now, this code seems to work fine, I can change AnyPC to many different machines where I know who is logged on and it returns the correct user.  But I've now come across 2 machines where it returns a users name who does Not even have a profile on the machine.   How accurate is this key?  I have a larger script that depends on this data being 100% accurate and it does not appear to be.   

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles