0

I want to know at which hour I logged in to my current session, I don't think uptime in Task Manager is what I'm looking for, because based on my understanding uptime is not the same as current user logged in time.

Is there any PowerShell command I can use in Windows to determine how long I have been logged in to the current session?

Task manager screenshot

Above is the image of my task manger, how can up time be 7 days? I dont understand.

MC10
  • 9,564
  • 4
  • 37
  • 52
Ace
  • 121
  • 7
  • You're correct, system uptime is an entirely different kettle of ghoti from user logged-in time. For a thorough explanation of Task Manager Up Time, see [this answer](https://superuser.com/a/1622932/330527) on similar question. – Peregrino69 Apr 05 '23 at 18:03
  • 1
    ... and searching for something entirely unrelated this popped up on the side panel of a site :-D https://winbuzzer.com/2021/03/12/how-to-check-uptime-on-windows-10-with-task-manager-powershell-or-command-prompt-xcxwbt – Peregrino69 Apr 05 '23 at 18:06
  • 1
    'uptime' is essentially a unix construct. It doesn't care how much you've been active at the computer, or how much time it slept. It simply measures 'time since last reboot'. – Tetsujin Apr 05 '23 at 18:16
  • 1
    Are you trying to find out how long since the PC has been turned on or how long since the user logged in? Those are two different questions in your title and body, it's confusing. – MC10 Apr 05 '23 at 18:21
  • I usually look in the security log for entries ID: 4624 where the Login Type is 2 . https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4624 – Frank Thomas Apr 05 '23 at 20:28

1 Answers1

3

query

Note: query.exe requires Windows 10 Pro and higher, and does not exist on Windows 10 Home. See this question for more information: How to get query command on Windows 10

You can run the command query user to find how long your user session has been logged in for. There is also a shorter quser (thanks @Destroy666!). Works in both CMD or PowerShell.

Use LOGON TIME to find out when you logged in and calculate from there.

PowerShell screenshot

net

You can also run the net stats workstation command. It will show you Statistics since ... the time you logged in.

CMD screenshot

MC10
  • 9,564
  • 4
  • 37
  • 52
  • 3
    This also works as shorter `quser` and it doesn't require PowerShell as it's just an executable located in `C:\Windows\System32` – Destroy666 Apr 05 '23 at 18:42
  • Good to know, thanks! PowerShell is in the example since OP mentioned they wanted to use PowerShell, but yes it's not required. – MC10 Apr 05 '23 at 18:45
  • `quser` is not present in all the versions of windows it not in home version – Ace Apr 06 '23 at 04:56
  • @Yanjan.Kaf. I see, yeah `query` is only available in Windows 10 Pro and higher. Does Windows 10 Home have access to the `net` command? You can try `net stats workstation` – MC10 Apr 06 '23 at 05:26