User Management

Assigning licenses to multiple users

Scenario description

In a previous scenario we showed you how to assign a license to a single user.  Assigning licenses to multiple users requires a few easy steps but the time spent here will pay off quickly as it is a much faster process.

To aid you in this process we have also included commands to export a list of unlicensed users and the command to retrieve a list of your available licensing options.

Connect to Azure Active Directory and assign Office 365 licenses to multiple users

To begin, you will need to connect to Azure Active Directory.
Import-Module MSOnline
$credential = get-credential
Connect-MsolService -Credential $credential
Export a list of unlicensed users to CSV for validation before making licensing changes.
Get-MsolUser -UnlicensedUsersOnly | export-csv c:\reports\Unlicensed_Users.CSV

This script will perform the following actions:

1. Show you the list of available licenses, their SKU codes, and the quantity remaining for assignment.

2. Display a list of unlicensed users for validation before making licensing changes.

3. Retrieve a list of all unlicensed users located in the United States (based on user property information), and assigns to the 'US' usage location for Office 365.

4. Will assign the EnterprisePack license to all unlicensed users, with a usage location of 'US', in the Contoso domain.

You must replace the Contoso domain for your domain name. Replace EnterprisePack for the license type of your choice.

Get-MsolAccountSku

Get-MsolUser -All -UnlicensedUsersOnly | where {$_.Country -eq 'United States'}

Get-MsolUser -All -UnlicensedUsersOnly | where {$_.Country -eq 'United States'} | Set-MsolUser -UsageLocation US

Get-MsolUser -All -UnlicensedUsersOnly -UsageLocation 'US' | Set-MsolUserLicense -AddLicenses "contoso:ENTERPRISEPACK"