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 https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

Import-PSSession $Session

Connect-Msolservice

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:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: