PasswordLastSet change format

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of bvi1998 . bvi1998 . 2 years, 2 months ago.

  • Author
    Posts
  • #18687
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    Hi,
    I am using get-adcomputer to get the PasswordLastSet date. I would like to change this to yyyy-mm-dd. Can someone help me with this? I've tried some things with no luck at all.
    Thanks!

  • #18689
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    ah, just got it:

    $d = $Computername.PasswordLastSet
    $d = $d.ToShortDateString()

    🙂

  • #18691
    Profile photo of Jason Hofferle
    Jason Hofferle
    Participant

    Since PasswordLastSet is a System.DateTime object, it can be manipulated in all the same ways. The ToString() method can be used to specify exactly how the date should be formatted.

    $computer = Get-ADComputer Computer01 -Properties PasswordLastSet
    $computer.PasswordLastSet.ToString("yyyy-MM-dd")

    http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx

  • #18692
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    Way better, thanks!

You must be logged in to reply to this topic.