Bulk Assign Office 365 User Licenses with PowerShell: Step-by-Step Guide
Table of Contents
Introduction:
Managing user licenses in Office 365 can be a time-consuming task, especially when dealing with multiple users. This guide will walk you through how to efficiently assign licenses to multiple users at once using PowerShell scripts, saving you valuable time and ensuring accurate license assignments.
We will utilize PowerShell, a powerful tool for automating tasks in Office 365 environments, to streamline the process of assigning user licenses.
Step-by-Step Instructions:
1: Connect to Office 365 PowerShell:
- Open PowerShell with administrative privileges.
- Run the following command to connect to Office 365
2: Prepare the License Sku:
Identify the license SKU you want to assign. You can list all available SKUs with:
Get-MsolAccountSku
3: Create a CSV File with User Information:
Create a CSV file with columns for UserPrincipalName and LicenseAssignment:
UserPrincipalName, LicenseAssignment
[email protected], ENTERPRISEPACK
[email protected], ENTERPRISEPACK
4: Assign Licenses to Users:
Run the following PowerShell script to assign licenses to users in bulk:
$Users = Import-Csv -Path "C:\Path\to\Your\File.csv"
foreach ($User in $Users) {
Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses "TENANT:ENTERPRISEPACK"
}
5: Verify License Assignments:
To verify that the licenses have been assigned correctly, you can run:
Get-MsolUser | ft UserPrincipalName, Licenses
Helpful Tips:
- Ensure that the CSV file is correctly formatted with the UserPrincipalName and LicenseAssignment columns.
- Double-check the license SKU names before running the script to avoid errors.
- Test the script with a small number of users first to ensure it works as expected.
Summary:
By following these steps, you can efficiently assign Office 365 user licenses in bulk using PowerShell scripts. This method not only saves time but also ensures accurate and consistent license assignments across multiple users. If you’re also interested in creating single or bulk users in Office 365, refer to this helpful guide: Effortless User Account Creation in Office 365 with PowerShell: Single & Bulk User Setup Guide. For further automation, consider exploring PowerShell scripts for other Office 365 management tasks.