Author Posts

April 7, 2017 at 9:36 pm

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?

April 10, 2017 at 1:53 am

Hi Christopher,

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

(Get-Date).AddDays(7)
(Get-Date).AddDays(-7)

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?

April 11, 2017 at 6:42 pm

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”)}}