Skip to content

Commit 72d6afe

Browse files
authored
Merge pull request #78744 from yyuank/patch-4
Update groups-settings-cmdlets.md
2 parents 529a85c + 094a465 commit 72d6afe

File tree

1 file changed

+63
-46
lines changed

1 file changed

+63
-46
lines changed

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

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ Office 365 Groups settings are configured using a Settings object and a Settings
3030

3131
The cmdlets are part of the Azure Active Directory PowerShell V2 module. For instructions how to download and install the module on your computer, see the article [Azure Active Directory PowerShell Version 2](https://docs.microsoft.com/powershell/azuread/). You can install the version 2 release of the module from [the PowerShell gallery](https://www.powershellgallery.com/packages/AzureAD/).
3232

33-
## Retrieve a specific settings value
34-
If you know the name of the setting you want to retrieve, you can use the below cmdlet to retrieve the current settings value. In this example, we're retrieving the value for a setting named "UsageGuidelinesUrl." You can read more about directory settings and their names further down in this article.
3533

36-
```powershell
37-
(Get-AzureADDirectorySetting).Values | Where-Object -Property Name -Value UsageGuidelinesUrl -EQ
38-
```
3934

4035
## Create settings at the directory level
4136
These steps create settings at directory level, which apply to all Office 365 groups in the directory. The Get-AzureADDirectorySettingTemplate cmdlet is available only in the [Azure AD PowerShell Preview module for Graph](https://www.powershellgallery.com/packages/AzureADPreview/2.0.0.137).
@@ -70,21 +65,27 @@ These steps create settings at directory level, which apply to all Office 365 gr
7065
4. Then update the usage guideline value:
7166

7267
```powershell
73-
$setting["UsageGuidelinesUrl"] = "https://guideline.example.com"
68+
$Setting["UsageGuidelinesUrl"] = "https://guideline.example.com"
7469
```
75-
5. Finally, apply the settings:
70+
5. Then apply the setting:
7671

7772
```powershell
78-
New-AzureADDirectorySetting -DirectorySetting $setting
73+
Set-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id -DirectorySetting $Setting
7974
```
80-
81-
Upon successful completion, the cmdlet returns the ID of the new settings object:
75+
6. You can read the values using:
8276

8377
```powershell
84-
Id DisplayName TemplateId Values
85-
-- ----------- ---------- ------
86-
c391b57d-5783-4c53-9236-cefb5c6ef323 62375ab9-6b52-47ed-826b-58e47e0e304b {class SettingValue {...
87-
```
78+
$Setting.Values
79+
```
80+
## Update settings at the directory level
81+
To update the value for UsageGuideLinesUrl in the setting template, simply edit the URL with Step 4 above, then perform Step 5 to set the new value.
82+
83+
To remove the value of UsageGuideLinesUrl, edit the URL to be an empty string using Step 4 above:
84+
85+
```powershell
86+
$Setting["UsageGuidelinesUrl"] = ""
87+
```
88+
Then perform Step 5 to set the new value.
8889

8990
## Template settings
9091
Here are the settings defined in the Group.Unified SettingsTemplate. Unless otherwise indicated, these features require an Azure Active Directory Premium P1 license.
@@ -105,7 +106,42 @@ Here are the settings defined in the Group.Unified SettingsTemplate. Unless othe
105106
| <ul><li>AllowToAddGuests<li>Type: Boolean<li>Default: True | A boolean indicating whether or not is allowed to add guests to this directory.|
106107
| <ul><li>ClassificationList<li>Type: String<li>Default: “” |A comma-delimited list of valid classification values that can be applied to Office 365 Groups. |
107108

109+
## Example: Configure Guest policy for groups at the directory level
110+
1. Get all the setting templates:
111+
```powershell
112+
Get-AzureADDirectorySettingTemplate
113+
```
114+
2. To set guest policy for groups at the directory level, you need Group.Unified template
115+
```powershell
116+
$Template = Get-AzureADDirectorySettingTemplate -Id 62375ab9-6b52-47ed-826b-58e47e0e304b
117+
```
118+
3. Next, create a new settings object based on that template:
119+
120+
```powershell
121+
$Setting = $template.CreateDirectorySetting()
122+
```
123+
4. Then update AllowToAddGuests setting
124+
```powershell
125+
$Setting["AllowToAddGuests"] = $False
126+
```
127+
5. Then apply the setting:
128+
129+
```powershell
130+
Set-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id -DirectorySetting $Setting
131+
```
132+
6. You can read the values using:
133+
134+
```powershell
135+
$Setting.Values
136+
```
137+
108138
## Read settings at the directory level
139+
140+
If you know the name of the setting you want to retrieve, you can use the below cmdlet to retrieve the current settings value. In this example, we're retrieving the value for a setting named "UsageGuidelinesUrl."
141+
142+
```powershell
143+
(Get-AzureADDirectorySetting).Values | Where-Object -Property Name -Value UsageGuidelinesUrl -EQ
144+
```
109145
These steps read settings at directory level, which apply to all Office groups in the directory.
110146

111147
1. Read all existing directory settings:
@@ -124,7 +160,7 @@ These steps read settings at directory level, which apply to all Office groups i
124160
Get-AzureADObjectSetting -TargetObjectId ab6a3887-776a-4db7-9da4-ea2b0d63c504 -TargetType Groups
125161
```
126162

127-
3. Read all directory settings values of a specific directory settings object, using Settings Id GUID:
163+
3. Read all directory settings values of a specific directory settings object, using Settings ID GUID:
128164
```powershell
129165
(Get-AzureADDirectorySetting -Id c391b57d-5783-4c53-9236-cefb5c6ef323).values
130166
```
@@ -146,6 +182,12 @@ These steps read settings at directory level, which apply to all Office groups i
146182
EnableGroupCreation True
147183
```
148184

185+
## Remove settings at the directory level
186+
This step removes settings at directory level, which apply to all Office groups in the directory.
187+
```powershell
188+
Remove-AzureADDirectorySetting –Id c391b57d-5783-4c53-9236-cefb5c6ef323c
189+
```
190+
149191
## Update settings for a specific group
150192

151193
1. Search for the settings template named "Groups.Unified.Guest"
@@ -162,51 +204,26 @@ These steps read settings at directory level, which apply to all Office groups i
162204
```
163205
2. Retrieve the template object for the Groups.Unified.Guest template:
164206
```powershell
165-
$Template = Get-AzureADDirectorySettingTemplate -Id 08d542b9-071f-4e16-94b0-74abb372e3d9
207+
$Template1 = Get-AzureADDirectorySettingTemplate -Id 08d542b9-071f-4e16-94b0-74abb372e3d9
166208
```
167209
3. Create a new settings object from the template:
168210
```powershell
169-
$Setting = $Template.CreateDirectorySetting()
211+
$SettingCopy = $Template1.CreateDirectorySetting()
170212
```
171213

172214
4. Set the setting to the required value:
173215
```powershell
174-
$Setting["AllowToAddGuests"]=$False
216+
$SettingCopy["AllowToAddGuests"]=$False
175217
```
176218
5. Create the new setting for the required group in the directory:
177219
```powershell
178-
New-AzureADObjectSetting -TargetType Groups -TargetObjectId ab6a3887-776a-4db7-9da4-ea2b0d63c504 -DirectorySetting $Setting
179-
180-
Id DisplayName TemplateId Values
181-
-- ----------- ---------- ------
182-
25651479-a26e-4181-afce-ce24111b2cb5 08d542b9-071f-4e16-94b0-74abb372e3d9 {class SettingValue {...
183-
```
184-
185-
## Update settings at the directory level
186-
187-
These steps update settings at directory level, which apply to all Office 365 groups in the directory. These examples assume there is already a Settings object in your directory.
188-
189-
1. Find the existing Settings object:
190-
```powershell
191-
$setting = Get-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id
220+
New-AzureADObjectSetting -TargetType Groups -TargetObjectId ab6a3887-776a-4db7-9da4-ea2b0d63c504 -DirectorySetting $SettingCopy
192221
```
193-
2. Update the value:
194-
195-
```powershell
196-
$Setting["AllowToAddGuests"] = "false"
197-
```
198-
3. Update the setting:
199-
222+
6. To verify the settings, run this command:
200223
```powershell
201-
Set-AzureADDirectorySetting -Id c391b57d-5783-4c53-9236-cefb5c6ef323 -DirectorySetting $Setting
224+
Get-AzureADObjectSetting -TargetObjectId ab6a3887-776a-4db7-9da4-ea2b0d63c504 -TargetType Groups | fl Values
202225
```
203226

204-
## Remove settings at the directory level
205-
This step removes settings at directory level, which apply to all Office groups in the directory.
206-
```powershell
207-
Remove-AzureADDirectorySetting –Id c391b57d-5783-4c53-9236-cefb5c6ef323c
208-
```
209-
210227
## Cmdlet syntax reference
211228
You can find more Azure Active Directory PowerShell documentation at [Azure Active Directory Cmdlets](/powershell/azure/install-adv2?view=azureadps-2.0).
212229

0 commit comments

Comments
 (0)