[SOLVED] Get-ADuser -property pwdLastSet giving wrong year?

Hi!

Doing som scriptbuilding and came across this strange thing, and want so hear if anybody else gets this.
When running Get-ADuser “username” -property pwdLastSet you get the property pwdLastSet. Take this number and run Get-Date (number from pwdLastSet).

The issue here is that i get something like this back: 28.feb.0415. In my mind that is incorrect. It should have ended with 2015, not 0415. Whats going on? Anyone else getting this?

You can use the PasswordLastSet property to get a correctly formatted date.

Or you can use this to convert that specific integer: [datetime]::fromfiletimeutc(number from pwdLastSet)

thanks! That is great! But, is this “normal”, that pwdLastSet is giving a string that is acting like that with get-date? Do you see the same behavior on your environment if you have one available?

Yes, I get the same output you get when I feed that long number to Get-Date.

The number stored in AD is the miliseconds since 1/1/1600. However it looks like if you give Get-Date a long integer, it assumes that this is miliseconds since 1/1/0000. That’s why the date is exactly 1600 years off.

aha, makes sense. thanks for the clarification - have a nice day! :slight_smile: