Skip to content

Instantly share code, notes, and snippets.

@nicolonsky
Last active July 11, 2025 19:43
Show Gist options
  • Select an option

  • Save nicolonsky/becf40be21d4bdaf5c6f262df5a3d35c to your computer and use it in GitHub Desktop.

Select an option

Save nicolonsky/becf40be21d4bdaf5c6f262df5a3d35c to your computer and use it in GitHub Desktop.
Connect-AzureAD
$runAsAccountServicePrincipal = Get-AzureADServicePrincipal -ObjectId "497421d0-5b78-4cf1-bab1-6ad2e3d7f319"
$accountAdminDirectoryRole= Get-AzureADDirectoryRole | where-object {$_.DisplayName -eq "User Account Administrator"}
Add-AzureADDirectoryRoleMember -ObjectId $accountAdminDirectoryRole.ObjectId `
-RefObjectId $runAsAccountServicePrincipal.ObjectId
Get-AzureADDirectoryRoleMember -ObjectId $accountAdminDirectoryRole.ObjectId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment