Add Users To Office 365 With Windows PowerShell
Add Users To Office 365 With Windows PowerShell
You can use the Azure Active Directory Module for Windows PowerShell cmdlets to add a group of users
to Office 365, or to license a group of users. You can also use the cmdlets to license users individually.
This article contains procedures to license users. For these procedures, we’re assuming you installed the
Azure Active Directory Module for Windows PowerShell and that you have a shortcut for it on your
desktop. You also have to be a global administrator on your Office 365 tenant. To run the examples in
the procedures, open the shortcut and type the commands at the Azure Active Directory Module for
Windows PowerShell command prompt.
Don’t have the module installed? See Manage Azure AD using Windows PowerShell for download
instructions and cmdlet syntax.
Type Connect-MsolService at the command prompt and enter your global administrator
credentials in the dialog box that pops up.
After you enter your credentials, you’ll be connected to your Microsoft Online services for as long as the
Azure Active Directory Module for Windows PowerShell command prompt is open.
Get your Office 365 plan information by using the Get-MsolAccountSku cmdlet
When you add users to Office 365, you’ll need to assign them a license to one of your Office 365 plans.
You can find out which plans that you (or your organization) own by running the Get-MsolAccountSku
cmdlet.
The output for Get-MsolAccountSku lists the AccountSkuId, ActiveUnits, WarningUnits, and
ConsumedUnits as follows:
In this case, the output means that you have the Enterprise plan, and you have used 21 of the available
25 licenses. This means you can add four more units to this tenant.
When you take a look at the New-MsolUser cmdlet syntax, you can see that it has many parameters, but
only -DisplayName and –UserPrincipalName are required. It’s up to you to decide what information you
want to store, but commonly first name, last name, and location are also included. This will create a
user. To assign the license, use the –LicenseAssignment option.
To add a single user, for example, Caleb Sills, to the Contoso tenant and give him a license to the
“ENTERPRISEPACK,” type:
-LicenseAssignment contoso:ENTERPRISEPACK
-LicenseAssignment contoso:ENTERPRISEPACK
The password has to be strong, meaning it has to contain at least one upper case character and at least
one number.
You can use a comma-separated values (CSV) file to add multiple users at the same time. In this
example, you create a CSV file with columns for Department, DisplayName, FirstName, LastName,
Password, UsageLocation, and UserPrincipalName. You add data for three users and then use Azure
Active Directory Module for Windows PowerShell to add them at the same time. This example CSV file
also contains a starter password.
DisplayNam FirstNam LastNam UsageLocatio
Department Password UserPrincipalName
e e e n
P@33word [email protected]
IT LynneB Lynne Baxter US
2 m
-LicenseAssignment 'contoso:ENTERPRISEPACK' `
For a more advanced example with sample scripts, see How to Use PowerShell to Automatically Assign
Licenses to Your Office 365 Users.