get-aduser fields AccountExpirationDate / accountExpires

we have used the get-aduser command to pull all attributes about all our user accounts. the output for the accountExpirationDate and accountExpires fields is in a bizarre format, e.g. "9223372036854770000", and I need a way, perhaps in excel, to convert it to a meaningful date. I have found a formula to covert the lastlogintimestamp to a meaningful date, so wondered if that would work here, or if anyone has any proven way of converting them.

I am also keen to understand what each field represents, e.g. if you add an expiry date for an AD account, which of accountExpirationDate  and accountExpires would be populated?
LVL 4
pma111Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sunil ChauhanLead AdministratorCommented:
you can convert it within the powershell below is one example.

get-aduser userid | select Name, @{N="AccountExpires";E={[DateTime]::FromFileTime($_.AccountExpires)}}

Open in new window

0
Lasse BodilsenSystem AdministratorCommented:
When i query Get-AdUser, i get a readable result in AccountExpirationDate, but not in accountExpires.  

BUT: accountExpires do seem to be auto populated. so i don't think you should change that.

But to set the expiration date i would use:
Set-ADAccountExpiration -Identity User -DateTime '12/12/2017 10:00:00'

Open in new window

0
Klavs RDeveloper, owner of AlbusBitCommented:
You can try my AD querying tool - AD FastReporter Free.
It converts all fields into meaningful values, including accountExpires. You can then export data to csv, xlsx, and html formats.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Discover the Answer to Productive IT

Discover app within WatchGuard's Wi-Fi Cloud helps you optimize W-Fi user experience with the most complete set of visibility, troubleshooting, and network health features. Quickly pinpointing network problems will lead to more happy users and most importantly, productive IT.

pma111Author Commented:
I was hoping to do this 'after the event', in excel now I have done some filtering of the initial PowerShell report, rather than starting from scratch and pulling a fresh export from AD via PowerShell.
0
Lasse BodilsenSystem AdministratorCommented:
@Klavs R:
Thank you for the tip, seems like a great tool.
0
Klavs RDeveloper, owner of AlbusBitCommented:
If you have found a formula for lastLogonTimestamp conversion then it will work for accountExpires too, because both are in the same format.
Just keep in mind - value of 0 or 0x7FFFFFFFFFFFFFFF (9223372036854775807) indicates that the account never expires.
0
pma111Author Commented:
thank you!
0
Klavs RDeveloper, owner of AlbusBitCommented:
Question solved.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.