Office 365 – How to disable password policy settings in BPOS and Office 365 with PowerShell

The Metaphorix office has fully embraced the move to the cloud and has Office 365 and Sharepoint Online.

As with all new releases of Microsoft products there is always an adjustment period where you are learning to customize options to suit individuals and company working practises.

One thing which you might want to change is the password policy settings in Office 365, I think by default it prompts you to change password every month.

if you want to change this or to stop it then this excellent article goes through how to do it step by step.

One word of warning it does use powershell so you will need a bit of scripting knowledge and the correct privileges.

This is the code which you will need to run

 

Password Policy change to never expire in Office 365

In office 365 you need only two lines to disable the password policy. First open the Microsoft Online Services Modul for Windows Powershell. (Download: 32bit or 64bit).

Connect to Office 365

Connect-MsolService

In the dialog enter the credentials of an administrator:

image

To change a single user:

Set-MsolUser -UserPrincipalName <username> -PasswordNeverExpires $True

To change all users at once:

Get-MsolUser | Set-MsolUser -PasswordNeverExpires $True

image

That’s it. You can control the result with the following command:

Get-MsolUser | fl

Password Policy change to never expire in BPOS

You can also change the password policy for former BPOS accounts. Here we use a csv-File, which contains all enabled users: First of all you need PowerShell for Migration (Download 32bit and 64bit).

Our first step is to export all users to a csv-File.

$Cred = Get-Credential
Get-MSOnlineUser -Credential $Cred -Enabled | select-object -property Identity | export-csv C:\data\user.csv

Now you find a csv-File with your enabled BPOS Users.

Our Script looks like that:

$Cred = Get-Credential
$Users = Import-Csv -Path "C:\data\user.csv"
ForEach($User in $Users)
{
$User.Identity
Set-MSOnlineUserPasswordNeverExpire –Identity $User.Identity –PasswordNeverExpire $true –Credential $Cred
}

Save the script as disableexpire.ps1 in the same directory as your user.csv file.

In PowerShell start the script with this command:

&"C:\Data\disableexpire.ps1"

This is the result:

image

All user account expiration settings have been changed.

 

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s