olpanis
olpanis

Reputation: 25

How can I get a list of accounts for users that have logged onto a machine?

I am looking for a way, to find out, which users have ever been logged on a local windows 10 machine by using PowerShell.

By using

Get-WmiObject -Class Win32_UserAccount -Filter  "LocalAccount='True'"

I get a list of users, but I think this is not complete, because there are more home directories than the list says.

Upvotes: 2

Views: 1381

Answers (1)

user2121604
user2121604

Reputation: 96

This will get all the cached accounts that has been logged into a computer. Note that there are ways to clear this, so there's the possibillity that someone else has been logged in, but cleared the traces. Make sure to run as administrator if lastusetime is of interest.

Get-CimInstance win32_userprofile -verbose | Select localpath, lastusetime

(You can remove -verbose if you don't want the operation to show, and of course Select for the stuff you are interested in)

Upvotes: 2

Related Questions