Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moiaune/f76b8351adcf49fd574938b4aac5ff0b to your computer and use it in GitHub Desktop.
Save moiaune/f76b8351adcf49fd574938b4aac5ff0b to your computer and use it in GitHub Desktop.
$spForApp = Get-AzADServicePrincipal -ApplicationId $app.AppId
if (-not ($spForApp)) {
$spForApp = New-AzADServicePrincipal -ApplicationId $app.AppId
foreach ($permission in $requiredPermissions) {
Add-AzADAppPermission -ObjectId $app.Id -ApiId $apiId -PermissionId $permission
}
Write-Verbose -Message "Azure Service Principal created: $($spForApp.Id)"
} else {
Write-Verbose -Message "Service Principal already exists"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment