Created
October 7, 2013 22:01
-
-
Save krohrbaugh/6875688 to your computer and use it in GitHub Desktop.
Windows Azure Active Directory: Add role to service principal
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
# Using the Windows Azure Active Directory Module for Windows PowerShell | |
# | |
# Connect to the tenant to modify | |
Connect-MsolService # => login | |
# Get Service Principal to add the role to | |
$servicePrincipal = Get-MsolServicePrincipal -ServicePrincipalName Principal.Name | |
# Get role object ID | |
# Alternatively, you can list all the roles (in order to get a different role name) using just `Get-MsolRole` | |
$roleId = (Get-MsolRole -RoleName "Directory Readers").ObjectId | |
# Add role to service principal | |
Add-MsolRoleMember -RoleObjectId $roleId -RoleMemberObjectId $servicePrincipal.ObjectId -RoleMemberType servicePrincipal | |
# Check our work | |
Get-MsolRoleMember -RoleObjectId $roleId # => should include Principal.Name in list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
like