is there a way to extract ONLY the Date from msDS-UserPasswordExpiryTimeComputed

Welcome Forums General PowerShell Q&A is there a way to extract ONLY the Date from msDS-UserPasswordExpiryTimeComputed

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
2 months, 2 weeks ago.

  • Author
    Posts
  • #164394

    Participant
    Topics: 1
    Replies: 0
    Points: 17
    Rank: Member

    Please see the following example:

    @{Name="ExpiryDate";Expression={[DateTime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

    outputs something like this: "7/5/2019 6:23"

    what I would like is "7/5/2019"

     

    Any form of help / suggestions are highly appreciated.

    Thank you.

  • #164457

    Participant
    Topics: 1
    Replies: 1529
    Points: 2,587
    Helping Hand
    Rank: Community Hero

    If you have a DateTime object you can use all its methods and properties. You can show them like this:

    Get-Date | Get-Member

    There you can see something like "ToShortDateString". Adapted to your code snippet this would lead to something like this:

    @{Name="ExpiryDate";Expression={([DateTime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")).ToShortDateString()}}

You must be logged in to reply to this topic.