To
retrieve a list of users who have both PowerApps Premium and Power Automate
Premium licenses, you can use a PowerShell script. Below is a step-by-step
guide to accomplish this. The script will use the Microsoft Graph API to query
the necessary license details.
Prerequisites
- Microsoft
Graph PowerShell Module: Ensure you have the Microsoft.Graph PowerShell module
installed.
- Admin
Permissions: Ensure you have the required permissions to query user
licenses.
- Azure
AD App Registration: Register an app in Azure AD and grant the necessary
API permissions to read user licenses.
Steps
- Install
Microsoft Graph PowerShell Module:
PowerShell
Install-Module
Microsoft.Graph -Scope CurrentUser
- Connect
to Microsoft Graph:
PowerShell
Connect-MgGraph
-Scopes "User.Read.All"
- PowerShell
Script:
PowerShell
#
Define the SKU IDs for PowerApps Premium and Power Automate Premium
$PowerAppsPremiumSkuId
= "c68f8d98-5534-43a8-9110-0d174bc7c6e3" # Replace with actual SKU ID
for PowerApps Premium
$PowerAutomatePremiumSkuId
= "9c0dab89-a30c-4bfd-8a92-6dff3f1d8d04" # Replace with actual SKU ID
for Power Automate Premium
#
Get all users in the organization
$users
= Get-MgUser -All
#
Filter users who have both licenses
$usersWithBothLicenses
= @()
foreach
($user in $users) {
# Get the user's license details
$userLicenseDetails = Get-MgUserLicenseDetails
-UserId $user.Id
# Check if the user has both licenses
$hasPowerAppsPremium = $userLicenseDetails.SkuId
-contains $PowerAppsPremiumSkuId
$hasPowerAutomatePremium = $userLicenseDetails.SkuId
-contains $PowerAutomatePremiumSkuId
if ($hasPowerAppsPremium -and $hasPowerAutomatePremium)
{
$usersWithBothLicenses += $user
}
}
#
Output the list of users with both licenses
$usersWithBothLicenses
| Select-Object DisplayName, UserPrincipalName
Explanation
- SKU
IDs: Replace the placeholders for PowerAppsPremiumSkuId and PowerAutomatePremiumSkuId with the actual SKU
IDs for those licenses. You can retrieve the SKU IDs by listing all
available licenses using the Graph API.
- Get-MgUser:
Retrieves all users in the organization.
- Get-MgUserLicenseDetails:
Retrieves the license details for each user.
- Filtering:
The script checks if each user has both the PowerApps Premium and Power
Automate Premium licenses. If so, the user is added to the list.
Running the Script
- Open
PowerShell with administrative privileges.
- Run
the script above.
- The
script will output the list of users who have both PowerApps Premium and
Power Automate Premium licenses.
No comments:
Post a Comment