Set passwords to never expire in office 365

First, Enable .net 3.5 on your system.

Then, Download and Install Microsoft Online Services Sign-In Assistant

Microsoft Online Services Sign-In Assistant 64-bit (BETA) – <a title=”Microsoft Online Services Sign-In Assistant 64-bit (BETA) – http://www.microsoft.com/en-my/download/details.aspx?id=39267

Then Download and install Microsoft Online Services Module for Windows PowerShell

Microsoft Online Services Module for Windows PowerShell 64-bit – http://g.microsoftonline.com/0BX10EN/423

Restart computer and start “Microsoft Online Services Module for Windows PowerShell”

Type the command:  Connect-MsolService

And in the dialog enter the credentials of your Office 365 administrator

To control if a password for a single user expires
Get-MSOLUser -UserPrincipalName <user ID> | Select PasswordNeverExpires

To change the password policy to never expire for a single user
Set-MsolUser -UserPrincipalName <user ID> -PasswordNeverExpires $true

To change the password policy to never expire for all users at once
Type the command: Get-MsolUser | Set-MsolUser -PasswordNeverExpires $True

To control that the modifications have been applied
Type the command “Get-MsolUser | fl”

And if you need to apply password policy to users

To change the password policy to expire for a single user
Set-MsolUser -UserPrincipalName <user ID> -PasswordNeverExpires $false

To change the password policy to expire for all users at once
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $false