Created
May 3, 2019 21:44
-
-
Save JonathonAnderson/382000cf83ae94f70ece27610c047e69 to your computer and use it in GitHub Desktop.
Finding logged on users, concept
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get Currently logged in user | |
$ExplorerProcess = gwmi win32_process | where name -Match explorer | |
if($ExplorerProcess.getowner().user.count -gt 1){ | |
$LoggedOnUser = $ExplorerProcess.getowner().user[0] | |
} | |
else{ | |
$LoggedOnUser = $ExplorerProcess.getowner().user | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment