Skip to content

Instantly share code, notes, and snippets.

@kshire
Created August 31, 2021 13:14
Show Gist options
  • Select an option

  • Save kshire/878bb5a567e88d5f1a810fefdface30e to your computer and use it in GitHub Desktop.

Select an option

Save kshire/878bb5a567e88d5f1a810fefdface30e to your computer and use it in GitHub Desktop.
Get-CimInstance -ClassName Win32_NetworkLoginProfile -ComputerName $env:COMPUTERNAME |
Where-Object { $_.UserType -match 'Normal Account' -and $_.Privileges -match '1' } |
Sort-Object -Property LastLogon -Descending |
Select-Object -Property Name, FullName, LastLogon, PSComputerName -First 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment