You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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/).
30
30
31
31
## Install the Azure AD PowerShell module
32
+
32
33
To install the Azure AD PowerShell module, use the following commands:
33
34
35
+
```powershell
34
36
PS C:\Windows\system32> install-module azuread
35
37
PS C:\Windows\system32> import-module azuread
38
+
```
36
39
37
40
To verify that the module is ready to use, use the following command:
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).
46
51
47
52
## Connect to the directory
53
+
48
54
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:
49
55
56
+
```powershell
50
57
PS C:\Windows\system32> Connect-AzureAD
58
+
```
51
59
52
60
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:
The cmdlet now returns the group whose objectID matches the value of the parameter you entered:
74
89
90
+
```powershell
75
91
DeletionTimeStamp :
76
92
ObjectId : e29bae11-4ac0-450c-bc37-6dae8f3da61b
77
93
ObjectType : Group
@@ -86,9 +102,11 @@ The cmdlet now returns the group whose objectID matches the value of the paramet
86
102
ProvisioningErrors : {}
87
103
ProxyAddresses : {}
88
104
SecurityEnabled : True
105
+
```
89
106
90
107
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:
@@ -106,18 +124,24 @@ You can search for a specific group using the -filter parameter. This parameter
106
124
ProvisioningErrors : {}
107
125
ProxyAddresses : {}
108
126
SecurityEnabled : True
127
+
```
109
128
110
-
> [!NOTE]
129
+
> [!NOTE]
111
130
> 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).
112
131
113
132
## Create groups
133
+
114
134
To create a new group in your directory, use the New-AzureADGroup cmdlet. This cmdlet creates a new security group called “Marketing":
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:
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:
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.
175
209
176
210
### Get members
211
+
177
212
To get the existing members of a group, use the Get-AzureADGroupMember cmdlet, as in this example:
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:
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
210
256
211
257
## 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.
213
260
214
261
To disable group creation for non-admin users:
215
262
216
263
1. Verify that non-admin users are allowed to create groups:
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.
234
284
235
285
To retrieve the owners of a group, use the Get-AzureADGroupOwner cmdlet:
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.
251
308
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/).
263
330
264
331
## Next steps
332
+
265
333
You can find more Azure Active Directory PowerShell documentation at [Azure Active Directory Cmdlets](/powershell/azure/install-adv2?view=azureadps-2.0).
266
334
267
335
*[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