Linux last equivalent for windows:  last logged in user on a Windows PC

por | 23 abril, 2025

 last logged in user on a Windows PC


Get-CimInstance -ClassName Win32_UserProfile | where {-not $_.Special} | select LocalPath, LastUseTime, @{ Name = 'DaysSinceLastUse'; Expression = { if ($_.LastUseTime) { ((Get-Date) - $_.LastUseTime).Days } } }


Example output:

LocalPath             LastUseTime         DaysSinceLastUse
---------             -----------         ----------------
C:\Users\the_andshrew 16/07/2023 11:32:16                0