TIP: Active Directory Module Date Properties

We have seen, it is very easy to get values like password expiration, when created and other such values utilizing Quest Active directory Module.

You can see above; how easy it is to get this information from the Quest AD module but what about if you want the same information from Microsoft Active Directory Module.

When you do the same with AD module, whenCreated is fine but other values such as accountexpires and pwdlastset is not friendly date format.

get-aduser testuser -Properties whenCreated,accountExpires,pwdLastSet | Select Name, whenCreated,accountExpires,pwdLastSet


There are different ways to get different things in this module:

For Account Expiry Date parameter that can be used is àAccountExpirationDate

get-aduser testuser -Properties whenCreated,accountExpirationdate | select Name, whenCreated,accountExpirationdate


For user password expiry date à @{N=”PasswordExpiryDate”;E={[datetime]::FromFileTime($_.”msDS-UserPasswordExpiryTimeComputed”)}}


For user pwdLastSet à @{N=”pwdLastSet”;E={[datetime]::FromFileTimeUtc($_.pwdLastSet)}}

get-aduser testuser -Properties whenCreated,accountExpires,pwdLastSet | select @{N=”pwdLastSet”;E={[datetime]::FromFileTimeUtc($_.pwdLastSet)}}


You can do the same with account expires property as well à @{N=”accountexpires”;E={[datetime]::FromFileTime($_.accountexpires)}}

get-aduser testuser1 -Properties whenCreated,accountExpires | select Name, Whencreated, @{N=”accountexpires”;E={[datetime]::FromFileTime($_.accountexpires)}}


I hope this TIP will help you in your day-to-day AD work.

 

 

Thanks for reading…..

Tech Wizard

https://techwizard.cloud

https://syscloudpro.com/

PowerShell Fast Track

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s