0% found this document useful (0 votes)
77 views

Add Users To Office 365 With Windows PowerShell

This document provides instructions for adding users to Office 365 using Windows PowerShell. It describes how to connect to Office 365 with Azure PowerShell, check your Office 365 plan and available licenses, add individual users and assign licenses, and add multiple users by importing a CSV file. The procedures assume the Azure Active Directory Module for Windows PowerShell is installed and the user has global administrator permissions for their Office 365 tenant.

Uploaded by

adminak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Add Users To Office 365 With Windows PowerShell

This document provides instructions for adding users to Office 365 using Windows PowerShell. It describes how to connect to Office 365 with Azure PowerShell, check your Office 365 plan and available licenses, add individual users and assign licenses, and add multiple users by importing a CSV file. The procedures assume the Azure Active Directory Module for Windows PowerShell is installed and the user has global administrator permissions for their Office 365 tenant.

Uploaded by

adminak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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.

Connect to Office 365 by using Azure PowerShell

 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.

Add users to Office 365 by using the New-MsolUser cmdlet

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.

Add a single Office 365 user

To add a single user, for example, Caleb Sills, to the Contoso tenant and give him a license to the
“ENTERPRISEPACK,” type:

New-MsolUser -DisplayName “Caleb Sills” -FirstName Caleb `

-LastName Sills -UserPrincipalName [email protected] `

–Department Operations -UsageLocation US `

-LicenseAssignment contoso:ENTERPRISEPACK

A random password gets assigned in the output:

You can assign a specific password by using the –Password parameter:

New-MsolUser -DisplayName “Caleb Sills” -FirstName Caleb `

-LastName Sills -UserPrincipalName [email protected] `

–Department Operations -UsageLocation US –PassWord TempP@@sW0rd `

-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.

Add multiple users to Office 365 at the same time

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

Melende P@33word [email protected]


Operations ShawnM Shawn US
z 1 om

P@33word [email protected]
IT LynneB Lynne Baxter US
2 m

Developme P@33word [email protected]


ClaudeL Claude Loiselle US
nt 3 om

Store the above CSV file in C:\Input\NewAssignments.csv, and type:

Import-Csv -Path C:\Input\NewAssignments.csv | ForEach-Object { `

New-MsolUser –Department $_.Department -FirstName $_.FirstName `

-DisplayName $_.DisplayName -LastName $_.LastName `

-Password $_.Password -UserPrincipalName $_.UserPrincipalName `

-LicenseAssignment 'contoso:ENTERPRISEPACK' `

-UsageLocation $_.UsageLocation}| Export-Csv -Path c:\output\LogNewAssignments.csv

Review the log file for information about license status.

For a more advanced example with sample scripts, see How to Use PowerShell to Automatically Assign
Licenses to Your Office 365 Users.

You might also like