Created
March 27, 2018 21:48
-
-
Save jpda/b34a852f1b7575cc98203d5d4c359078 to your computer and use it in GitHub Desktop.
add MSI service principal to approle
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
| # you may not need tenantId, but if it is ambiguous you should set it here | |
| Connect-AzureAd -TenantId | |
| # name of your MSI service principal, in my case msi-func. You can also get the ID from Enterprise Applications in AAD (not App Reg) | |
| $msifunc = Get-AzureADServicePrincipal -SearchString "msi-func" | |
| # name of your AAD service principal, in my case aad-func. You can also get the ID from App Registrations in AAD | |
| $aadapp = Get-AzureADServicePrincipal -SearchString "aad-func" | |
| # Id - the ID of the role. You can get it from the app's manifest | |
| # PrincipalId - the object ID of the MSI principal | |
| # ObjectId - the object ID of the MSI principal | |
| # ResourceId - the object ID of the AAD app | |
| New-AzureADServiceAppRoleAssignment -Id $aadapp.AppRoles[0].Id -PrincipalId $msifunc.ObjectId -ObjectId $msifunc.ObjectId -ResourceId $aadapp.ObjectId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment