Office 365 configuring a user to not expire via powershell

For those mentally transposing commands from Active Directory and Exchange via PowerShell, I had thought this might be useful in avoiding some pitfalls in your daily Azure admin tasks.

Before we had started, double-check the following pre-requisites for running Windows Azure Active Directory Module for Windows PowerShell.

a. Review software requirements.

http://technet.microsoft.com/en-us/library/jj151815.aspx#BKMK_Requirements

b. Install the Windows Azure AD Module for Windows PowerShell.

http://technet.microsoft.com/en-us/library/jj151815.aspx#bkmk_installmodule

So let us begin!

1. Under Microsoft Online Services, run as administrator the Microsoft Online Services Module for Windows PowerShell.

2. Enter; Connect-msolservice

3. When prompted, enter login credentials for an Office 365 administrative account.

4. Locate the User Principal Name for the account for editing.

NOTE: If unsure, export your entire list of users with the following command: Get-MSOLUser -All | export-csv c:\getusers.csv.

5. Run the following command, Set-MsolUserPassword to set a password. Reference the following example:

Set-MsolUserPassword -UserPrincipalName ellen.ripley@lv426.onmicrosoft.com -ForceChangePassword $False -NewPassword “Xenomorph#1”

6.  Setting user password not to expire, Get-MSOLUser | SetMsoluser. Reference the following example:

Get-MSOLUser -UserPrincipalName ellen.ripley@lv426.onmicrosoft.com | Set-MsolUser -PasswordNeverExpires $true

The key variable that had needed qualifying –UserPrincipalName. In Exchange and Active Directory, I had left  this open ended or closed with the –identity switch in PowerShell. Also, I had gotten tripped up with Boolean data for reference for –ForceChangePassword $False instead of “False” or False.

If you hadn’t typed the commands properly, expect some of the follow automated errors:

Get-MsolUser : A positional parameter cannot be found that accepts argument

Set-MsolUserPassword : Cannot convert ‘System.String’ to the type ‘System.Nullable`1[System.Boolean]’ required by parameter ‘ForceChangePassword’.

Read More:
Set-MsolUserPassword (Microsoft TechNet)
Get-MsolUser (Microsoft TechNet)
Set up user passwords to never expire (Office365)

20131028-211320.jpg

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