Calling Date Time Objects

I’m a total Noob at scripting…

I’m a total Noob at Powershell, Please Forgive me.

This is one of the suggested sentences to call Password Expired dates by another forum user. (@{Name=“ExpiryDate”;Expression={[datetime]::FromFileTime($_.“msDS-UserPasswordExpiryTimeComputed”)}} )

I’ve tried it and tweaked it’s -Searchbase paramaters and it is working.

However I would like to call Expiry date from “The current date” and checked against msDS-UserPasswordExpiryTimeComputed for expired passwords in the past 7 days and coming 7 days.

Can somebody recommend documentation on how to pipe Get-Date +/-7 and check against msDS-USerPasswordExpiryTimeComputed?

Hi Christopher,

Hopefully this can point you in the right direction. You can use something like:


To find +/- 7 days from the current date. However, I’m not sure how to incorporate that into your script, can you post a snippet where you are wanting to implement this?

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $false} -searchbase ‘dc=Example, dc=local’ –Properties “DisplayName”, “msDS-MaximumPasswordAge" |Select-Object -Property “Displayname”,@{Name=“ExpiryDate”;Expression={[datetime]::FromFileTime($_.“msDS-MaximumPasswordAge”)}}