Automate Office 365 License Assignment with PowerShell
In this post, we will introduce a PowerShell script that automates the assignment of Office 365 licenses to users in your organization. Managing licenses efficiently is crucial for ensuring that employees have access to the necessary resources for their roles. This script allows administrators to assign licenses in bulk, simplifying the user onboarding process and ensuring compliance with your organization’s licensing agreements.
Here is the PowerShell script for automating Office 365 license assignments:
# Connect to Microsoft 365 $credential = Get-Credential Connect-MsolService -Credential $credential # Define user details and license SKU $usersToLicense = @("[email protected]", "[email protected]") # List of users to assign licenses $licenseSku = "yourtenant:ENTERPRISEPACK" # Replace with your actual license SKU # Assign licenses to each user foreach ($user in $usersToLicense) { Set-MsolUserLicense -UserPrincipalName $user -AddLicenses $licenseSku Write-Host "Assigned license to $user successfully." }