![]()
Power Automate is a powerful tool from Microsoft that allows users to automate workflows and processes across multiple applications. However, to use Power Automate, users must have the appropriate licenses assigned to them. Managing these licenses manually via the Microsoft 365 admin center can be time-consuming, especially for large organizations. Fortunately, PowerShell provides an efficient way to automate this process.
In this guide, we will walk through the step-by-step process of assigning Power Automate licenses using PowerShell. We will cover prerequisites, connecting to Microsoft 365, retrieving users, assigning licenses, and verifying assignments.
Step 1: Prerequisites
Before we begin, ensure that you have the following:
- Administrator Account – You need a Microsoft 365 administrator account with permission to manage licenses.
- PowerShell Installed – Install the latest version of PowerShell if it’s not already installed.
- Microsoft Graph PowerShell Module – This module allows you to manage Microsoft 365 services.
- Azure AD PowerShell Module – This is required for user and license management.
Step 2: Install and Import Required PowerShell Modules
To interact with Microsoft 365 services, install the necessary modules if they are not already installed.
# Install Microsoft Graph PowerShell module
Install-Module Microsoft.Graph -Scope CurrentUser
# Install Azure AD PowerShell module
Install-Module AzureAD -Scope CurrentUser
# Import the installed modules
Import-Module Microsoft.Graph
Import-Module AzureAD
Step 3: Connect to Microsoft 365
After installing the necessary modules, connect to your Microsoft 365 account using the following command:
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All"
# Connect to Azure AD
Connect-AzureAD
You will be prompted to enter your administrator credentials.
Step 4: Retrieve Available Power Automate Licenses
Before assigning licenses, retrieve the list of available licenses in your tenant.
# Get all available licenses
Get-MgSubscribedSku | Select-Object SkuId, SkuPartNumber
This command will display a list of all available licenses. Look for the SKU related to Power Automate, such as:
- PowerAutomate_P1
- PowerAutomate_P2
Take note of the SkuId for the desired license.
Step 5: Retrieve User Details
Before assigning a license, retrieve the list of users who need Power Automate access.
# Get all users
Get-MgUser | Select-Object DisplayName, UserPrincipalName, Id
To find a specific user:
# Get a specific user
Get-MgUser -UserId "user@example.com" | Select-Object DisplayName, UserPrincipalName, Id
Step 6: Assign Power Automate License to a User
Now, assign the Power Automate license to a specific user. Replace "SkuIdValue" with the actual SkuId retrieved earlier.
# Define the User ID and License SKU
$UserId = "user@example.com"
$SkuId = "SkuIdValue"
# Assign the license
Set-MgUserLicense -UserId $UserId -AddLicenses @{SkuId=$SkuId} -RemoveLicenses @()
Step 7: Assign Power Automate License to Multiple Users
If you need to assign the license to multiple users at once, you can use a CSV file.
Step 7.1: Prepare a CSV File
Create a CSV file (e.g., Users.csv) with the following structure:
UserPrincipalName
user1@example.com
user2@example.com
user3@example.com
Step 7.2: Run the Bulk Assignment Script
# Read users from CSV file
$Users = Import-Csv -Path "C:\Path\To\Users.csv"
# Assign the license to each user
foreach ($User in $Users) {
$UserId = $User.UserPrincipalName
Set-MgUserLicense -UserId $UserId -AddLicenses @{SkuId=$SkuId} -RemoveLicenses @()
Write-Host "License assigned to $UserId"
}
Step 8: Verify License Assignments
After assigning licenses, verify if the users have received the correct licenses.
# Get a user's assigned licenses
Get-MgUserLicenseDetail -UserId "user@example.com"
To check all users who have the Power Automate license assigned:
# Get users with a specific license
Get-MgUser | Where-Object {($_.AssignedLicenses -match "SkuIdValue")} | Select-Object DisplayName, UserPrincipalName
Step 9: Revoke a Power Automate License
If you need to remove a license from a user, use the following command:
# Remove Power Automate license
Set-MgUserLicense -UserId "user@example.com" -AddLicenses @{} -RemoveLicenses @(@{SkuId="SkuIdValue"})
For bulk removal using a CSV file:
# Read users from CSV file
$Users = Import-Csv -Path "C:\Path\To\Users.csv"
# Remove the license from each user
foreach ($User in $Users) {
$UserId = $User.UserPrincipalName
Set-MgUserLicense -UserId $UserId -AddLicenses @{} -RemoveLicenses @(@{SkuId=$SkuId})
Write-Host "License removed from $UserId"
}
Step 10: Disconnect from Microsoft 365
Once you have assigned the licenses, disconnect from the Microsoft 365 session to ensure security.
Disconnect-MgGraph
Disconnect-AzureAD
