Calling Date Time Objects

This topic contains 2 replies, has 2 voices, and was last updated by  Christopher 11 months, 2 weeks ago.

  • Author
  • #68319


    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?

  • #68386

    Jeff Brown

    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?

  • #68520


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

You must be logged in to reply to this topic.