• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1000
  • Last Modified:

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?
0
pma111
Asked:
pma111
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
Sunil ChauhanExpertise in Exchange Server, Office 365 & Powershell ScriptingCommented:
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
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now