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.
b. Install the Windows Azure AD Module for Windows PowerShell.
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 email@example.com -ForceChangePassword $False -NewPassword “Xenomorph#1”
6. Setting user password not to expire, Get-MSOLUser | SetMsoluser. Reference the following example:
Get-MSOLUser -UserPrincipalName firstname.lastname@example.org | 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’.