Office 365 and PowerShell Cloud User Creation

Getting started with Office 365 and Powershell can be a bit confusing, partly because so many aspects have changed in a short time. This is really for my own notes, but I’ve made it generic and may help others:

Here’s a very brief rundown on how to set yourself up and start creating cloud users. For internal users, DirSync/AzureAD is a much better option, but you may have requirements for external parties to access your Office 365 environment in some way.

Install Microsoft Online Services Sign-In Assistant for IT Professionals

Install Azure AD Module

Launch Azure Active Directory PowerShell

Test connectivity to Azure/Office365 by adding account using command “connect-msolservice” – will get prompted for credentials.

Check you’re connected with a command such as “Get-MsolCompanyInformation”

Create a CSV with your users such as this:

Richard Sole,Richard,Sole,ILovePSv4,,

Run this script which will prompt for Azure credentials. This one is hardcoded for the AU region, but can be added as a variable to the CSV.

$data = import-csv -path C:\Temp\myusers.csv
foreach ($user in $data){
New-MsolUser -FirstName $user.FirstName -DisplayName $user.DisplayName -LastName $user.LastName -Password $user.Password -UserPrincipalName $user.UserPrincipalName -UsageLocation AU

Users are now created in Office 365!

You can store the credentials to be used, or use a certificate – this Azure article shows how


One thought on “Office 365 and PowerShell Cloud User Creation

Leave a Reply