Last active
May 26, 2026 15:29
-
-
Save joerodgers/6bd3603027b7d0c203d82b17f54ed76b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Microsoft.PowerApps.Administration.PowerShell" | |
| function Register-PowerPlatformAdminServicePrincipal | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Mandatory=$true)] | |
| [Guid] | |
| $ClientId | |
| ) | |
| begin | |
| { | |
| $accessToken = Get-JwtToken -Audience "https://api.bap.microsoft.com" | |
| $headers = @{ "Authorization" = "Bearer $accessToken"; "Content-Type" = "application/json"; "Accept" = "application/json" } | |
| } | |
| process | |
| { | |
| return Invoke-RestMethod ` | |
| -Uri "https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/adminApplications/${ClientId}?api-version=2020-10-01" ` | |
| -Method PUT ` | |
| -Headers $headers ` | |
| -ErrorAction Stop | |
| } | |
| end | |
| { | |
| } | |
| } | |
| function List-PowerPlatformAdminServicePrincipal | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| ) | |
| begin | |
| { | |
| $accessToken = Get-JwtToken -Audience "https://api.bap.microsoft.com" | |
| $headers = @{ "Authorization" = "Bearer $accessToken"; "Content-Type" = "application/json"; "Accept" = "application/json" } | |
| } | |
| process | |
| { | |
| return Invoke-RestMethod ` | |
| -Uri "https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/adminApplications?api-version=2020-10-01" ` | |
| -Method GET ` | |
| -Headers $headers ` | |
| -ErrorAction Stop | Select-Object -ExpandProperty value | |
| } | |
| end | |
| { | |
| } | |
| } | |
| # simple script to support - https://learn.microsoft.com/en-us/power-platform/admin/powerplatform-api-create-service-principal#registering-an-admin-management-application | |
| Register-PowerPlatformAdminServicePrincipal -ClientId $env:CDX_CLIENTID -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment