Set Passwords to Never Expire in Office 365 Using PowerShell

Just don’t do it!

However, there may be some cases where you are asked to break company policies and set an account to never expire. In smaller organizations this usually comes from the business owners or managers but try and resist for their own good and explain the security risks involved. When ever possible, compromise and come up with a suitable password policy for the business to use.

You could set the following password policy:

  • Changes every 90 days
  • 8 Characters long
  • Include upper and lower case
  • Include at least one number
  • Include a special character such as a full stop

If you don’t know how to connect PowerShell to your Office 365 account, read this first then come back:

http://www.slashadmin.co.uk/how-to-connect-powershell-to-office-365/

If you really need to set an account to never expire then you use the Get-MsolUser cmdlet and pipe the user object into the Set-MsolUser command to set the PasswordNeverExpires attribute to $True but you can always change it back by running the command again specifying $False.

In this example we set my account to never expire:

Get-MsolUser –UserPrincipalName ian.waters@office365lab.co.uk | Set-MsolUser –PasswordNeverExpires $True

Office 365 set password to never expire 1

If you really, really have to you can set all user passwords in Office 365 to never expire by running the cmdlet as follows:

Get-MsolUser | Set-MsolUser –PasswordNeverExpires $True

Office 365 set password to never expire 2

Summary

I urge you to never set passwords to never expire unless they are system accounts used with services such as AD Connect used to synchronise Active Directory. If you’re forced to do this, then at least ensure there is a suitably complex password policy in place.

Subscribe to the blog if you want to see my future tips, each week we I’ll post useful commands and scripts for you to learn from and experiment with.



Get this blog post sent to you as a PDF file to read later

Enter your email address and press Send Now


If you want to learn more you can buy my book from Amazon, either the paper back or kindle version. My advice is to buy the paperback version so you can keep it on your desk for easy reference!

Office 365 PowerShell Book

For paperback version click here

For Kindle version click here

 

Author: Ian@SlashAdmin

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.