@@ -9,7 +9,7 @@ ms.service: active-directory
9
9
ms.topic : how-to
10
10
ms.subservice : roles
11
11
ms.workload : identity
12
- ms.date : 03/22 /2022
12
+ ms.date : 05/09 /2022
13
13
ms.author : rolyon
14
14
ms.reviewer : anandy
15
15
ms.custom : oldportal;it-pro;
@@ -91,12 +91,11 @@ You can assign an Azure AD role with an administrative unit scope by using the A
91
91
### PowerShell
92
92
93
93
``` powershell
94
- $adminUser = Get-AzureADUser -ObjectId "Use the user's UPN, who would be an admin on this unit"
95
- $role = Get-AzureADDirectoryRole | Where-Object -Property DisplayName -EQ -Value "User Administrator"
96
- $adminUnitObj = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'The display name of the unit'"
97
- $roleMember = New-Object -TypeName Microsoft.Open.MSGraph.Model.MsRoleMemberInfo
98
- $roleMember.Id = $adminUser.ObjectId
99
- Add-AzureADMSScopedRoleMembership -Id $adminUnitObj.Id -RoleId $role.ObjectId -RoleMemberInfo $roleMember
94
+ $user = Get-AzureADUser -Filter "userPrincipalName eq 'Example_UPN'"
95
+ $roleDefinition = Get-AzureADMSRoleDefinition -Filter "displayName eq 'Example_role_name'"
96
+ $adminUnit = Get-AzureADMSAdministrativeUnit -Filter "displayName eq 'Example_admin_unit_name'"
97
+ $directoryScope = '/administrativeUnits/' + $adminUnit.Id
98
+ $roleAssignment = New-AzureADMSRoleAssignment -DirectoryScopeId $directoryScope -RoleDefinitionId $roleDefinition.Id -PrincipalId $user.objectId
100
99
```
101
100
102
101
You can change the highlighted section as required for the specific environment.
@@ -137,8 +136,8 @@ You can view all the role assignments created with an administrative unit scope
137
136
### PowerShell
138
137
139
138
``` powershell
140
- $adminUnitObj = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'The display name of the unit '"
141
- Get-AzureADMSScopedRoleMembership -Id $adminUnitObj .Id | fl *
139
+ $adminUnit = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'Example_admin_unit_name '"
140
+ Get-AzureADMSScopedRoleMembership -Id $adminUnit .Id | fl *
142
141
```
143
142
144
143
You can change the highlighted section as required for your specific environment.
0 commit comments