I think I have it, or at least I have enough to figure out what I need.
Get-MsolUser -userprincipalname user@domain.org | select DisplayName, LastPasswordChangeTimeStamp,@{Name=”PasswordAge”;Expression={(Get-Date)-$_.LastPasswordChangeTimeStamp}}
The result looks like this (date and time format will match your computer's):
DisplayName LastPasswordChangeTimestamp PasswordAge
----------- --------------------------- -----------
User, Name 09-Mar-16 5:48p 42.22:34:10.6964630
.
In order to see all users whose passwords are older than 30 days, use this.
Get-MsolUser -All | select DisplayName, LastPasswordChangeTimeStamp,@{Name=”PasswordAge”;Expression={(Get-Date)-$_.LastPasswordChangeTimeStamp}} | where {$_.PasswordAge -gt “30”} | sort-object PasswordAge -descending
It will list all of the users with passwords older than 30 days and sort the list by the password age.
I hope this helps others as well.
What's so different about this answer that's not already mentioned in the other answer again? Also, if you determine this is indeed not a duplicated answer then consider clarifying and add a little more context to this answer to convey what you are suggesting exactly and why it works, etc. You know, consider adding some reference to this answer supporting what you state and why it is. – Pimp Juice IT – 2017-08-16T23:53:49.283
I see the difference. A more accurate list will result by doing the calculation against UTC since that's the dates and times that PS uses. Without the added expression, there would be a few hours difference as it calculated against the computer time instead of UTC. Is that correct @Toby? – Jono – 2017-08-18T11:03:01.510