Skip to content

Instantly share code, notes, and snippets.

@JonathonAnderson
Created May 3, 2019 21:44
Show Gist options
  • Save JonathonAnderson/382000cf83ae94f70ece27610c047e69 to your computer and use it in GitHub Desktop.
Save JonathonAnderson/382000cf83ae94f70ece27610c047e69 to your computer and use it in GitHub Desktop.
Finding logged on users, concept
#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