2

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?

ChaChaPoly
  • 1,811
  • 5
  • 17
  • 39
  • Maybe this helps you https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status – TobyU Oct 04 '18 at 12:49
  • @TobyU I have checked that question, but none of the provided answers satisfy the requirements – ChaChaPoly Oct 04 '18 at 13:04

1 Answers1

4

The below one line will return a list of logged on users.

query user /server:PcHostname
SAIDI Belkacem
  • 338
  • 4
  • 13