Random programming things I'd want to remember

Thursday, May 9, 2013

Get the info on when user last set his/her password

I needed to find out when user changed password last time and I though I would use PowerShell. There are plenty of examples in Google, but most of them refer to cases when user accounts are controlled by Active Directory. I found some script, and modified it to the extent that I was getting the number of seconds since the last time the password was changed. I learned a lot about PowerShell, too, it is great to have a .Net environment for quick tasks like that without having to compile anything.

Anyway, I found a simple solution:

net user USERNAME | find "last set"

And that did the trick.