Skip to content

Commit 469a96a

Browse files
Merge pull request #79600 from curtand/yuan0613
[Azure AD groups] writeback preview for O365 groups
2 parents aa52b17 + 2a97d77 commit 469a96a

File tree

1 file changed

+91
-23
lines changed

1 file changed

+91
-23
lines changed

articles/active-directory/users-groups-roles/groups-settings-v2-cmdlets.md

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: PowerShell examples for managing groups - Azure Active Directory | Microsoft Docs
2+
title: PowerShell examples for managing groups and preview group writeback to on-premises - Azure Active Directory | Microsoft Docs
33
description: This page provides PowerShell examples to help you manage your groups in Azure Active Directory
44
keywords: Azure AD, Azure Active Directory, PowerShell, Groups, Group management
55
services: active-directory
@@ -10,7 +10,7 @@ ms.service: active-directory
1010
ms.workload: identity
1111
ms.subservice: users-groups-roles
1212
ms.topic: article
13-
ms.date: 01/31/2019
13+
ms.date: 06/14/2019
1414
ms.author: curtand
1515

1616
ms.reviewer: krbain
@@ -29,49 +29,65 @@ ms.collection: M365-identity-device-management
2929
This article contains examples of how to use PowerShell to manage your groups in Azure Active Directory (Azure AD). It also tells you how to get set up with the Azure AD PowerShell module. First, you must [download the Azure AD PowerShell module](https://www.powershellgallery.com/packages/AzureAD/).
3030

3131
## Install the Azure AD PowerShell module
32+
3233
To install the Azure AD PowerShell module, use the following commands:
3334

35+
```powershell
3436
PS C:\Windows\system32> install-module azuread
3537
PS C:\Windows\system32> import-module azuread
38+
```
3639

3740
To verify that the module is ready to use, use the following command:
3841

42+
```powershell
3943
PS C:\Windows\system32> get-module azuread
4044
4145
ModuleType Version Name ExportedCommands
4246
---------- --------- ---- ----------------
4347
Binary 2.0.0.115 azuread {Add-AzureADAdministrati...}
48+
```
4449

4550
Now you can start using the cmdlets in the module. For a full description of the cmdlets in the Azure AD module, please refer to the online reference documentation for [Azure Active Directory PowerShell Version 2](/powershell/azure/install-adv2?view=azureadps-2.0).
4651

4752
## Connect to the directory
53+
4854
Before you can start managing groups using Azure AD PowerShell cmdlets, you must connect your PowerShell session to the directory you want to manage. Use the following command:
4955

56+
```powershell
5057
PS C:\Windows\system32> Connect-AzureAD
58+
```
5159

5260
The cmdlet prompts you for the credentials you want to use to access your directory. In this example, we are using [email protected] to access the demonstration directory. The cmdlet returns a confirmation to show the session was connected successfully to your directory:
5361

62+
```powershell
5463
Account Environment Tenant
5564
------- ----------- ------
5665
[email protected] AzureCloud 85b5ff1e-0402-400c-9e3c-0f…
66+
```
5767

5868
Now you can start using the AzureAD cmdlets to manage groups in your directory.
5969

6070
## Retrieve groups
71+
6172
To retrieve existing groups from your directory, use the Get-AzureADGroups cmdlet.
6273

6374
To retrieve all groups in the directory, use the cmdlet without parameters:
6475

76+
```powershell
6577
PS C:\Windows\system32> get-azureadgroup
78+
```
6679

6780
The cmdlet returns all groups in the connected directory.
6881

6982
You can use the -objectID parameter to retrieve a specific group for which you specify the group’s objectID:
7083

84+
```powershell
7185
PS C:\Windows\system32> get-azureadgroup -ObjectId e29bae11-4ac0-450c-bc37-6dae8f3da61b
86+
```
7287

7388
The cmdlet now returns the group whose objectID matches the value of the parameter you entered:
7489

90+
```powershell
7591
DeletionTimeStamp :
7692
ObjectId : e29bae11-4ac0-450c-bc37-6dae8f3da61b
7793
ObjectType : Group
@@ -86,9 +102,11 @@ The cmdlet now returns the group whose objectID matches the value of the paramet
86102
ProvisioningErrors : {}
87103
ProxyAddresses : {}
88104
SecurityEnabled : True
105+
```
89106

90107
You can search for a specific group using the -filter parameter. This parameter takes an ODATA filter clause and returns all groups that match the filter, as in the following example:
91108

109+
```powershell
92110
PS C:\Windows\system32> Get-AzureADGroup -Filter "DisplayName eq 'Intune Administrators'"
93111
94112
@@ -106,18 +124,24 @@ You can search for a specific group using the -filter parameter. This parameter
106124
ProvisioningErrors : {}
107125
ProxyAddresses : {}
108126
SecurityEnabled : True
127+
```
109128

110-
> [!NOTE]
129+
> [!NOTE]
111130
> The Azure AD PowerShell cmdlets implement the OData query standard. For more information, see **$filter** in [OData system query options using the OData endpoint](https://msdn.microsoft.com/library/gg309461.aspx#BKMK_filter).
112131
113132
## Create groups
133+
114134
To create a new group in your directory, use the New-AzureADGroup cmdlet. This cmdlet creates a new security group called “Marketing":
115135

136+
```powershell
116137
PS C:\Windows\system32> New-AzureADGroup -Description "Marketing" -DisplayName "Marketing" -MailEnabled $false -SecurityEnabled $true -MailNickName "Marketing"
138+
```
117139

118140
## Update groups
141+
119142
To update an existing group, use the Set-AzureADGroup cmdlet. In this example, we’re changing the DisplayName property of the group “Intune Administrators.” First, we’re finding the group using the Get-AzureADGroup cmdlet and filter using the DisplayName attribute:
120143

144+
```powershell
121145
PS C:\Windows\system32> Get-AzureADGroup -Filter "DisplayName eq 'Intune Administrators'"
122146
123147
@@ -135,15 +159,17 @@ To update an existing group, use the Set-AzureADGroup cmdlet. In this example, w
135159
ProvisioningErrors : {}
136160
ProxyAddresses : {}
137161
SecurityEnabled : True
162+
```
138163

139164
Next, we’re changing the Description property to the new value “Intune Device Administrators”:
140165

166+
```powershell
141167
PS C:\Windows\system32> Set-AzureADGroup -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df -Description "Intune Device Administrators"
168+
```
142169

143-
Now if we find the group again, we see the Description property is updated to reflect the new value:
144-
145-
PS C:\Windows\system32> Get-AzureADGroup -Filter "DisplayName eq 'Intune Administrators'"
170+
Now, if we find the group again, we see the Description property is updated to reflect the new value:
146171

172+
```powershell PS C:\Windows\system32> Get-AzureADGroup -Filter "DisplayName eq 'Intune Administrators'"
147173
148174
DeletionTimeStamp :
149175
ObjectId : 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df
@@ -159,109 +185,151 @@ Now if we find the group again, we see the Description property is updated to re
159185
ProvisioningErrors : {}
160186
ProxyAddresses : {}
161187
SecurityEnabled : True
188+
```
162189

163190
## Delete groups
191+
164192
To delete groups from your directory, use the Remove-AzureADGroup cmdlet as follows:
165193

194+
```powershell
166195
PS C:\Windows\system32> Remove-AzureADGroup -ObjectId b11ca53e-07cc-455d-9a89-1fe3ab24566b
196+
```
197+
198+
## Manage group membership
167199

168-
## Manage group membership
169200
### Add members
201+
170202
To add new members to a group, use the Add-AzureADGroupMember cmdlet. This command adds a member to the Intune Administrators group we used in the previous example:
171203

204+
```powershell
172205
PS C:\Windows\system32> Add-AzureADGroupMember -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df -RefObjectId 72cd4bbd-2594-40a2-935c-016f3cfeeeea
206+
```
173207

174208
The -ObjectId parameter is the ObjectID of the group to which we want to add a member, and the -RefObjectId is the ObjectID of the user we want to add as a member to the group.
175209

176210
### Get members
211+
177212
To get the existing members of a group, use the Get-AzureADGroupMember cmdlet, as in this example:
178213

214+
```powershell
179215
PS C:\Windows\system32> Get-AzureADGroupMember -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df
180216
181217
DeletionTimeStamp ObjectId ObjectType
182218
----------------- -------- ----------
183219
72cd4bbd-2594-40a2-935c-016f3cfeeeea User
184220
8120cc36-64b4-4080-a9e8-23aa98e8b34f User
221+
```
185222

186223
### Remove members
224+
187225
To remove the member we previously added to the group, use the Remove-AzureADGroupMember cmdlet, as is shown here:
188226

227+
```powershell
189228
PS C:\Windows\system32> Remove-AzureADGroupMember -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df -MemberId 72cd4bbd-2594-40a2-935c-016f3cfeeeea
229+
```
190230

191231
### Verify members
232+
192233
To verify the group memberships of a user, use the Select-AzureADGroupIdsUserIsMemberOf cmdlet. This cmdlet takes as its parameters the ObjectId of the user for which to check the group memberships, and a list of groups for which to check the memberships. The list of groups must be provided in the form of a complex variable of type “Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck”, so we first must create a variable with that type:
193234

235+
```powershell
194236
PS C:\Windows\system32> $g = new-object Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck
237+
```
195238

196239
Next, we provide values for the groupIds to check in the attribute “GroupIds” of this complex variable:
197240

241+
```powershell
198242
PS C:\Windows\system32> $g.GroupIds = "b11ca53e-07cc-455d-9a89-1fe3ab24566b", "31f1ff6c-d48c-4f8a-b2e1-abca7fd399df"
243+
```
199244

200245
Now, if we want to check the group memberships of a user with ObjectID 72cd4bbd-2594-40a2-935c-016f3cfeeeea against the groups in $g, we should use:
201246

247+
```powershell
202248
PS C:\Windows\system32> Select-AzureADGroupIdsUserIsMemberOf -ObjectId 72cd4bbd-2594-40a2-935c-016f3cfeeeea -GroupIdsForMembershipCheck $g
203249
204250
OdataMetadata Value
205251
------------- -----
206252
https://graph.windows.net/85b5ff1e-0402-400c-9e3c-0f9e965325d1/$metadata#Collection(Edm.String) {31f1ff6c-d48c-4f8a-b2e1-abca7fd399df}
207-
253+
```
208254

209255
The value returned is a list of groups of which this user is a member. You can also apply this method to check Contacts, Groups or Service Principals membership for a given list of groups, using Select-AzureADGroupIdsContactIsMemberOf, Select-AzureADGroupIdsGroupIsMemberOf or Select-AzureADGroupIdsServicePrincipalIsMemberOf
210256

211257
## Disable group creation by your users
212-
You can prevent non-admin users from creating security groups. The default behavior in Microsoft Online Directory Services (MSODS) is to allow non-admin users to create groups, whether or not self-service group management (SSGM) is also enabled. The SSGM setting controls behavior only in the My Apps access panel.
258+
259+
You can prevent non-admin users from creating security groups. The default behavior in Microsoft Online Directory Services (MSODS) is to allow non-admin users to create groups, whether or not self-service group management (SSGM) is also enabled. The SSGM setting controls behavior only in the My Apps access panel.
213260

214261
To disable group creation for non-admin users:
215262

216263
1. Verify that non-admin users are allowed to create groups:
217264

218-
```
265+
```powershell
219266
PS C:\> Get-MsolCompanyInformation | fl UsersPermissionToCreateGroupsEnabled
220267
```
221268

222269
2. If it returns `UsersPermissionToCreateGroupsEnabled : True`, then non-admin users can create groups. To disable this feature:
223270

224-
```
271+
```powershell
225272
Set-MsolCompanySettings -UsersPermissionToCreateGroupsEnabled $False
226273
```
227274

228275
## Manage owners of groups
276+
229277
To add owners to a group, use the Add-AzureADGroupOwner cmdlet:
230278

279+
```powershell
231280
PS C:\Windows\system32> Add-AzureADGroupOwner -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df -RefObjectId 72cd4bbd-2594-40a2-935c-016f3cfeeeea
281+
```
232282

233283
The -ObjectId parameter is the ObjectID of the group to which we want to add an owner, and the -RefObjectId is the ObjectID of the user or service principal we want to add as an owner of the group.
234284

235285
To retrieve the owners of a group, use the Get-AzureADGroupOwner cmdlet:
236286

287+
```powershell
237288
PS C:\Windows\system32> Get-AzureADGroupOwner -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df
289+
```
238290

239291
The cmdlet returns the list of owners (users and service principals) for the specified group:
240292

293+
```powershell
241294
DeletionTimeStamp ObjectId ObjectType
242295
----------------- -------- ----------
243296
e831b3fd-77c9-49c7-9fca-de43e109ef67 User
297+
```
244298

245299
If you want to remove an owner from a group, use the Remove-AzureADGroupOwner cmdlet:
246300

301+
```powershell
247302
PS C:\Windows\system32> remove-AzureADGroupOwner -ObjectId 31f1ff6c-d48c-4f8a-b2e1-abca7fd399df -OwnerId e831b3fd-77c9-49c7-9fca-de43e109ef67
303+
```
304+
305+
## Reserved aliases
248306

249-
## Reserved aliases
250307
When a group is created, certain endpoints allow the end user to specify a mailNickname or alias to be used as part of the email address of the group. Groups with the following highly privileged email aliases can only be created by an Azure AD global administrator. 
251308

252-
* abuse
253-
* admin
254-
* administrator
255-
* hostmaster
256-
* majordomo
257-
* postmaster
258-
* root
259-
* secure
260-
* security
261-
* ssl-admin
262-
* webmaster
309+
* abuse
310+
* admin
311+
* administrator
312+
* hostmaster
313+
* majordomo
314+
* postmaster
315+
* root
316+
* secure
317+
* security
318+
* ssl-admin
319+
* webmaster
320+
321+
## Group writeback to on-premises (preview)
322+
323+
Today, many groups are still managed in on-premises Active Directory. To answer requests to sync cloud groups back to on-premise, Office 365 groups writeback feature for Azure AD is now available for preview.
324+
325+
Office 365 groups are created and managed in the cloud. The writeback capability allows you to write back Office 365 groups as distribution groups to an Active Directory forest with Exchange installed. Users with on-premises Exchange mailboxes can then send and receive emails from these groups. The group writeback feature doesn't support Azure AD security groups or distribution groups.
326+
327+
For more details, please refer to documentation for the [Azure AD Connect sync service](../hybrid/how-to-connect-syncservice-features.md).
328+
329+
Office 365 group writeback is a public preview feature of Azure Active Directory (Azure AD) and is available with any paid Azure AD license plan. For some legal information about previews, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
263330

264331
## Next steps
332+
265333
You can find more Azure Active Directory PowerShell documentation at [Azure Active Directory Cmdlets](/powershell/azure/install-adv2?view=azureadps-2.0).
266334

267335
* [Managing access to resources with Azure Active Directory groups](../fundamentals/active-directory-manage-groups.md?context=azure/active-directory/users-groups-roles/context/ugr-context)

0 commit comments

Comments
 (0)