Powershell Logged In Users

#powershell #windows
Most scripts to find logged in users either look for users who have logged in since last boot, or only look at locally logged in users (not RDP sessions)

A hacky but clever way of doing this is looking for running explorer.exe processes:

gwmi win32_process -f 'Name = "explorer.exe"'|% getowner|% user