Remove password expiration Office 365

Remove password expiration Office 365

I wrote this powershell script to remove password expiration for all users, so that the users password not expires

Password_expiration.ps1

$Cred = Get-Credential

Read-Host 'Press Enter to continue to Connect to Office 365' | Out-Null
Write-Host "Continueing..."
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic –AllowRedirection

Import-PSSession $s

Read-Host 'Press Enter to continue to remove password from expires for all users' | Out-Null
Write-Host "Continueing..."
Connect-MsolService –Credential $cred

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true

Read-Host 'Press Enter to exit script, All Done' | Out-Null

Leave a Reply