1. Click Start > All Programs > Accessories > Windows PowerShell > Windows PowerShell. Right click it to run as administrator.
2. Run the following command:
$Cred = Get-Credential
3. In the Windows PowerShell Credential Request window that opens, type the credentials of an account in your cloud-based organization. When you are finished, click OK.
4. Run the following command:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Note The AllowRedirection parameter enables cloud-based organizations in datacenters all over the world to connect Windows PowerShell to the cloud-based service by using the same URL.
5. Run the following command:
A progress indicator appears that shows the importing of commands used in the cloud-based service into the client-side session of your local computer. When this process is complete, you can run these commands.
6. Run the following command to set password to never expire.
Get-MSOLUser | Set-MSOLUser –PasswordNeverExpires $true