Skip to content

Commit 2d631b9

Browse files
authored
Merge pull request #212208 from rolyon/rolyon-aadroles-admin-units-members-powershell
[Azure AD roles] [Admin units] Members Graph PowerShell
2 parents ef48c3c + 090a2bb commit 2d631b9

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

articles/active-directory/roles/admin-units-members-add.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ ms.collection: M365-identity-device-management
1818

1919
# Add users, groups, or devices to an administrative unit
2020

21-
> [!IMPORTANT]
22-
> Administrative units support for devices is currently in PREVIEW.
23-
> See the [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/) for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
24-
2521
In Azure Active Directory (Azure AD), you can add users, groups, or devices to an administrative unit to restrict the scope of role permissions. Adding a group to an administrative unit brings the group itself into the management scope of the administrative unit, but **not** the members of the group. For additional details on what scoped administrators can do, see [Administrative units in Azure Active Directory](administrative-units.md).
2622

2723
This article describes how to add users, groups, or devices to administrative units manually. For information about how to add users or devices to administrative units dynamically using rules, see [Manage users or devices for an administrative unit with dynamic membership rules](admin-units-members-dynamic.md).
@@ -31,8 +27,7 @@ This article describes how to add users, groups, or devices to administrative un
3127
- Azure AD Premium P1 or P2 license for each administrative unit administrator
3228
- Azure AD Free licenses for administrative unit members
3329
- Privileged Role Administrator or Global Administrator
34-
- AzureAD module when using PowerShell
35-
- AzureADPreview module when using PowerShell for devices
30+
- Microsoft Graph PowerShell
3631
- Admin consent when using Graph explorer for Microsoft Graph API
3732

3833
For more information, see [Prerequisites to use PowerShell or Graph Explorer](prerequisites.md).
@@ -125,47 +120,51 @@ You can add users, groups, or devices to administrative units using the Azure po
125120

126121
## PowerShell
127122

128-
Use the [Add-AzureADMSAdministrativeUnitMember](/powershell/module/azuread/add-azureadmsadministrativeunitmember) command to add users or groups to an administrative unit.
129-
130-
Use the [Add-AzureADMSAdministrativeUnitMember (Preview)](/powershell/module/azuread/add-azureadmsadministrativeunitmember?view=azureadps-2.0-preview&preserve-view=true) command to add devices to an administrative unit.
131-
132-
Use the [New-AzureADMSAdministrativeUnitMember (Preview)](/powershell/module/azuread/new-azureadmsadministrativeunitmember) to create a new group in an administrative unit. Currently, only group creation is supported with this command.
123+
Use the [Invoke-MgGraphRequest](/powershell/microsoftgraph/authentication-commands#using-invoke-mggraphrequest) command to add user, groups, or devices to an administrative unit or create a new group in an administrative unit.
133124

134125
### Add users to an administrative unit
135126

136127
```powershell
137-
$adminUnitObj = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'Test administrative unit 2'"
138-
$userObj = Get-AzureADUser -Filter "UserPrincipalName eq 'bill@example.com'"
139-
Add-AzureADMSAdministrativeUnitMember -Id $adminUnitObj.Id -RefObjectId $userObj.ObjectId
128+
Invoke-MgGraphRequest -Method POST -Uri https://graph.microsoft.com/v1.0/directory/administrativeUnits/{ADMIN_UNIT_ID}/members/ -Body '{
129+
"@odata.id": "https://graph.microsoft.com/v1.0/users/{USER_ID}"
130+
}'
140131
```
141132

142133
### Add groups to an administrative unit
143134

144135
```powershell
145-
$adminUnitObj = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'Test administrative unit 2'"
146-
$groupObj = Get-AzureADGroup -Filter "displayname eq 'TestGroup'"
147-
Add-AzureADMSAdministrativeUnitMember -Id $adminUnitObj.Id -RefObjectId $groupObj.ObjectId
136+
Invoke-MgGraphRequest -Method POST -Uri https://graph.microsoft.com/v1.0/directory/administrativeUnits/{ADMIN_UNIT_ID}/members/ -Body '{
137+
"@odata.id": https://graph.microsoft.com/v1.0/groups/{GROUP_ID}
138+
}'
148139
```
149140

150141
### Add devices to an administrative unit
151142

152143
```powershell
153-
$adminUnitObj = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'Test administrative unit 2'"
154-
$deviceObj = Get-AzureADDevice -Filter "displayname eq 'TestDevice'"
155-
Add-AzureADMSAdministrativeUnitMember -Id $adminUnitObj.Id -RefObjectId $deviceObj.ObjectId
144+
Invoke-MgGraphRequest -Method POST -Uri https://graph.microsoft.com/v1.0/directory/administrativeUnits/{ADMIN_UNIT_ID}/members/ -Body '{
145+
"@odata.id": https://graph.microsoft.com/v1.0/devices/{DEVICE_ID}
146+
}'
156147
```
157148

158149
### Create a new group in an administrative unit
159150

160151
```powershell
161-
$exampleGroup = New-AzureADMSAdministrativeUnitMember -Id "<admin unit object id>" -OdataType "Microsoft.Graph.Group" -DisplayName "<Example group name>" -Description "<Example group description>" -MailEnabled $True -MailNickname "<examplegroup>" -SecurityEnabled $False -GroupTypes @("Unified")
152+
$exampleGroup = Invoke-MgGraphRequest -Method POST -Uri https://graph.microsoft.com/v1.0/directory/administrativeUnits/{ADMIN_UNIT_ID}/members/ -Body '{
153+
"@odata.type": "#Microsoft.Graph.Group",
154+
"description": "{Example group description}",
155+
"displayName": "{Example group name}",
156+
"groupTypes": [
157+
"Unified"
158+
],
159+
"mailEnabled": true,
160+
"mailNickname": "{exampleGroup}",
161+
"securityEnabled": false
162+
}'
162163
```
163164

164165
## Microsoft Graph API
165166

166-
Use the [Add a member](/graph/api/administrativeunit-post-members) API to add users or groups to an administrative unit.
167-
168-
Use the [Add a member (Beta)](/graph/api/administrativeunit-post-members?view=graph-rest-beta&preserve-view=true) API to add devices to an administrative unit or create a new group in an administrative unit.
167+
Use the [Add a member](/graph/api/administrativeunit-post-members) API to add users, groups, or devices to an administrative unit or create a new group in an administrative unit.
169168

170169
### Add users to an administrative unit
171170

@@ -220,14 +219,14 @@ Example
220219
Request
221220

222221
```http
223-
POST https://graph.microsoft.com/beta/administrativeUnits/{admin-unit-id}/members/$ref
222+
POST https://graph.microsoft.com/v1.0/directory/administrativeUnits/{admin-unit-id}/members/$ref
224223
```
225224

226225
Body
227226

228227
```http
229228
{
230-
"@odata.id":"https://graph.microsoft.com/beta/devices/{device-id}"
229+
"@odata.id":"https://graph.microsoft.com/v1.0/devices/{device-id}"
231230
}
232231
```
233232

@@ -236,7 +235,7 @@ Body
236235
Request
237236

238237
```http
239-
POST https://graph.microsoft.com/beta/administrativeUnits/{admin-unit-id}/members/
238+
POST https://graph.microsoft.com/v1.0/directory/administrativeUnits/{admin-unit-id}/members/
240239
```
241240

242241
Body

articles/active-directory/roles/prerequisites.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ ms.collection: M365-identity-device-management
2020

2121
If you want to manage Azure Active Directory (Azure AD) roles using PowerShell or Graph Explorer, you must have the required prerequisites. This article describes the PowerShell and Graph Explorer prerequisites for different Azure AD role features.
2222

23+
## Microsoft Graph PowerShell
24+
25+
To use PowerShell commands to do the following:
26+
27+
- Add users, groups, or devices to an administrative unit
28+
- Create a new group in an administrative unit
29+
30+
You must have the Microsoft Graph PowerShell SDK installed:
31+
32+
- [Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/installation)
33+
2334
## AzureAD module
2435

2536
To use PowerShell commands to do the following:

0 commit comments

Comments
 (0)