# PasswordLastSet change format

**URL:** <https://forums.powershell.org/t/passwordlastset-change-format/3081>\
**Category:** PowerShell Help\
**Created:** [September 10, 2014, 12:42am UTC](https://forums.powershell.org/t/passwordlastset-change-format/3081 "2014-09-10T00:42:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [September 10, 2014, 12:42am UTC](https://forums.powershell.org/t/passwordlastset-change-format/3081/1 "2014-09-10T00:42:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [September 10, 2014, 12:46am UTC](https://forums.powershell.org/t/passwordlastset-change-format/3081/2 "2014-09-10T00:46:50Z")

</div>

ah, just got it:

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

🙂

---

<div class="post-metadata">

**Author:** ![jhofferle](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jhofferle/32/804_2.png) [@jhofferle](https://forums.powershell.org/u/jhofferle)\
**Post date:** [September 10, 2014, 12:52am UTC](https://forums.powershell.org/t/passwordlastset-change-format/3081/3 "2014-09-10T00:52:28Z")

</div>

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](http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx)

---

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [September 10, 2014, 12:57am UTC](https://forums.powershell.org/t/passwordlastset-change-format/3081/4 "2014-09-10T00:57:56Z")

</div>

Way better, thanks!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:47pm UTC](https://forums.powershell.org/t/passwordlastset-change-format/3081/5 "2024-05-16T20:47:32Z")

</div>

Closed on May 16, 2024, 8:47pm UTC


