find the computer user last login

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 12 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
cymba
Posts: 23
Last visit: Wed Apr 27, 2011 8:42 am

find the computer user last login

Post by cymba »

Hi Jay,

wonder if you can help me?
I have a list of users I want to find the last time they logged in and the computer that was login to. i wonder if you have a powershell script that facilitate this?

Thanks in advance.
User avatar
cymba
Posts: 23
Last visit: Wed Apr 27, 2011 8:42 am

find the computer user last login

Post by cymba »

Hi Jay,

wonder if you can help me?
I have a list of users I want to find the last time they logged in and the computer that was login to. i wonder if you have a powershell script that facilitate this?

Thanks in advance.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

find the computer user last login

Post by jvierra »

In a domain the last logn time is held on the domain controllers. Just how toretrieve this depends on the level of the domain.

To find the machine lofgged into you would need to scan the Event log of the DC to find the login event then parse the record to obtain the machine name. This is also subject to domain configuration.

With Vista and later we can use Get-WinEvent. WIth earlier OS versions WMI is probably the best approach.

Look in the script sharing section for examples of reading the event log.


This topic is 12 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked