Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save joerodgers/6bd3603027b7d0c203d82b17f54ed76b to your computer and use it in GitHub Desktop.

Select an option

Save joerodgers/6bd3603027b7d0c203d82b17f54ed76b to your computer and use it in GitHub Desktop.
#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