Script to set all PW to never expire in O365

Following on from the previous post, here is the complete script. Copy and paste it into Powershell.

It will ask for Id and PW twice, please input.

$LiveCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $LiveCred -Authentication Basic -AllowRedirection

Import-PSSession $Session


Get-MsolUser | Set-MsolUser -PasswordNeverExpires $true

Get-MsolUser | Select UserPrincipalName, PasswordNeverExpires

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: