...Because someone's gotta tell the story...


To return to the main Blog List, click Full Blog Listing.


Site Updates

Powershell: Getting the locally logged in user (as SYSTEM)

Tuesday, April 16, 2013 in Powershell (Views: 1739)
Sometimes as you are scripting you need to get the locally logged on user, perhaps to drop a file on the desktop, or edit the HKU registry hive. You can easily do this by a WMI query.

In this example, I have removed the domain name (in this case, called DOMAIN).

$LocalUser=Get-WmiObject -Query "Select UserName from Win32_ComputerSystem"
write-host "Local User Is: "$LocalUser.UserName

Happy Scripting.


Related Blogs You May Be Interested In:

To leave a comment, please log in and/or register.