Sep
10
Published Monday, September 10, 2012 at 9:24 AM in Office
A common issue with Office 365 is the password policy that forces a password expiration every 90 days. So I wrote a PowerShell script that updates the entire organization with a Password Never Expires flag. However, the script must be executed everytime a new user is added to the organization, since it only applies the new rules for existing users.
First of all, you must install the Office 365 cmdlets from here:
http://onlinehelp.microsoft.com/en-us/office365-enterprises/hh124998.aspx#BKMK_install
Fire up PowerShell and execute the following:
$oUsername = "administrator@organization.com"
$oPassword = "administrator-password"
$password = ConvertTo-SecureString $oPassword -AsPlainText –Force
$credential = New-Object System.Management.Automation.PsCredential($oUsername,$password)
$cred = Get-Credential -cred $credential
Import-Module MSOnline
Connect-Msolservice -cred $cred
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true
Get-MSOLUser | Select UserPrincipalName,PasswordNeverExpires
The script will connect to Office 365 and fetch all existing users and apply the new rules to them. Then it will display a list of all users with the value of PasswordNeverExpires.