1

I know I can see the password dates (date last changed, date it will expire, etc.) for our in-house Active Directory. How do I see this information for Office 365 accounts, either with PowerShell or in any other way? This information is very handy to have at times. I especially need to see when people's passwords were changed.

Thanks, Jono

1

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.

1

Thought of sharing this here.

This script generates 7 different Office 365 password reports.

https://o365reports.com/2020/02/17/export-office-365-users-last-password-change-date-to-csv/

Using this script, you can generate following password reports.

  • Pwd Expiry Date Report
    • Pwd Last Change Date Report
    • Pwd Expired Users Report
    • Pwd Never Expires Users Report
    • Soon-to-Expire Pwd Users Report
    • Recently Pwd Changed Users Report
    • Password Report for Licensed Users

enter image description here

0

To properly calculate the Age against UTC time, you can use the ToUniversalTime() method.

Get-MsolUser -All | select DisplayName, LastPasswordChangeTimeStamp,@{Name=”PasswordAge”;Expression={((Get-Date).ToUniversalTime())-$_.LastPasswordChangeTimeStamp}} | sort-object PasswordAge -desc
2
  • 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. – Pillsbury IT Doughboy Aug 16 '17 at 23:53
  • 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 Aug 18 '17 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.