Find Current User via Powershell

sometimes if you run as local admin, but your current user is not a local admin, then you need some special way of finding the current username:

$user = (gwmi -Query “Select * from Win32_Process where name = ‘explorer.exe'”).GetOwner().User

Leave a Reply