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 has 1 reply, 2 voices, and was last updated 1 year ago by
    Participant
    .
Viewing 1 reply thread
  • 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: 5
      Replies: 2368
      Points: 5,987
      Helping Hand
      Rank: Community MVP

      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()}}
Viewing 1 reply thread
  • The topic ‘is there a way to extract ONLY the Date from msDS-UserPasswordExpiryTimeComputed’ is closed to new replies.