Created
October 7, 2016 12:50
-
-
Save irwinwilliams/b14d4b5dd972dff4e4342f110b35771b to your computer and use it in GitHub Desktop.
Set Roles in Azure AD via PowerShell
This file contains 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
#'I got this from here: https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console/issues/27#issuecomment-155565140 | |
$Tenant = "[something].onmicrosoft.com"; | |
$tenantGuid = "[find this in the manifest]" | |
$graphver = "1.5" | |
$appID = "[also manifest, but portal, too.]" | |
$userVal = "[username]@" + $tenant | |
$pass = "[password]" | |
$creds = New-Object System.Management.Automation.PsCredential($userVal, (ConvertTo-SecureString $pass -AsPlainText -Force)) | |
Connect-MsolService -Credential $creds | |
$msSP = Get-MsolServicePrincipal -AppPrincipalId $appID -TenantID $tenantGuid | |
#ID of the Application | |
$objectId = $msSP.ObjectId | |
$roleName = "Company Administrator" | |
Add-MsolRoleMember -RoleName $roleName -RoleMemberType ServicePrincipal -RoleMemberObjectId $objectId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment