Assigning Power Apps licenses using PowerShell ensures that users have the necessary access to Power Platform features without manually assigning licenses through the Microsoft 365 Admin Center. This approach is efficient for bulk assignments and automation in enterprise environments.
Step 1: Install Required PowerShell Modules
Before proceeding, install the necessary PowerShell modules:
Install-Module -Name AzureAD -Force
Install-Module -Name Microsoft.Graph -Scope CurrentUser -Force
If prompted, press Y to confirm installation.
Step 2: Authenticate to Microsoft 365 & Azure AD
Log in using an admin account with sufficient privileges to assign licenses:
Connect-AzureAD
Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All"
This grants permission to manage user licenses in the organization.
Step 3: Retrieve Available Power Apps Licenses in the Tenant
To list all Power Apps license types available in your organization:
Get-AzureADSubscribedSku | Select SkuPartNumber, SkuId
Look for Power Apps-related licenses, such as:
- POWERAPPS_PER_USER
- POWERAPPS_PER_APP
- POWERAPPS_PER_USER_TRIAL
- DYN365_CDS_VIRAL
Note the SkuId of the license you want to assign.
Step 4: Assign a Power Apps License to a Single User
Use the following command to assign a Power Apps license to a specific user:
$userEmail = "user@domain.com"
$user = Get-AzureADUser -Filter "UserPrincipalName eq '$userEmail'"
$licenseSku = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # Replace with actual SkuId
$license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$license.SkuId = $licenseSku
$licensePlan = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$licensePlan.AddLicenses = $license
Set-AzureADUserLicense -ObjectId $user.ObjectId -AssignedLicenses $licensePlan
Replace SkuId with the one retrieved in Step 3.
Step 5: Assign Power Apps Licenses to Multiple Users
To assign a Power Apps license to multiple users in bulk, use:
$users = @("user1@domain.com", "user2@domain.com", "user3@domain.com")
$licenseSku = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # Replace with actual SkuId
foreach ($userEmail in $users) {
$user = Get-AzureADUser -Filter "UserPrincipalName eq '$userEmail'"
if ($user) {
$license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$license.SkuId = $licenseSku
$licensePlan = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$licensePlan.AddLicenses = $license
Set-AzureADUserLicense -ObjectId $user.ObjectId -AssignedLicenses $licensePlan
Write-Host "License assigned to $userEmail"
} else {
Write-Host "User not found: $userEmail"
}
}
This script assigns the license to each user in the list and logs the results.
Step 6: Verify Assigned Licenses
To confirm that a user has been assigned a Power Apps license:
$userEmail = "user@domain.com"
$user = Get-AzureADUser -Filter "UserPrincipalName eq '$userEmail'"
Get-AzureADUserLicenseDetail -ObjectId $user.ObjectId | Select-Object SkuPartNumber
This displays the licenses assigned to the user.
Step 7: Disconnect from Microsoft 365
Once done, disconnect the session:
Disconnect-AzureAD
Disconnect-MgGraph