I am trying to view all users currently accessing my computer on Windows 10. Using the following Powershell command shows me all users:
(Get-CimInstance Win32_LoggedOnUser).antecedent.name | Select-Object -Unique
This is great, as it also shows users logged in via PSRemote sessions. So let's say user A
logs into my PC (PC-B
) via an interactive PSRemote session:
Enter-PSSession -ComputerName PC-B
It will show me that the user is logged on. Yet once user A
closes the PSRemote session, the username is still being listed. Also the Get-CimInstance
command also doesn't show users that might be accessing a specific network share on PC-B
.
Is there a way to view ALL users logged in, whether it is via Network Share, Remote, RDP or locally? Seeing users accessing a Network Share is not so important, but all other kinds are. Since the users in question are all domain users, do I have to query the DC?