Skip to content

Commit 5a2f6f7

Browse files
authored
Merge pull request #78985 from yyuank/patch-5
Update groups-settings-cmdlets.md
2 parents c101257 + 9fb1d5c commit 5a2f6f7

File tree

1 file changed

+51
-15
lines changed

1 file changed

+51
-15
lines changed

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

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ These steps create settings at directory level, which apply to all Office 365 gr
7474
```
7575
6. You can read the values using:
7676

77-
```powershell
77+
```powershell
7878
$Setting.Values
7979
```
8080
## Update settings at the directory level
8181
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.
8282

8383
To remove the value of UsageGuideLinesUrl, edit the URL to be an empty string using Step 4 above:
8484

85-
```powershell
85+
```powershell
8686
$Setting["UsageGuidelinesUrl"] = ""
8787
```
8888
Then perform Step 5 to set the new value.
@@ -108,7 +108,7 @@ Here are the settings defined in the Group.Unified SettingsTemplate. Unless othe
108108

109109
## Example: Configure Guest policy for groups at the directory level
110110
1. Get all the setting templates:
111-
```powershell
111+
```powershell
112112
Get-AzureADDirectorySettingTemplate
113113
```
114114
2. To set guest policy for groups at the directory level, you need Group.Unified template
@@ -131,17 +131,17 @@ Here are the settings defined in the Group.Unified SettingsTemplate. Unless othe
131131
```
132132
6. You can read the values using:
133133

134-
```powershell
134+
```powershell
135135
$Setting.Values
136136
```
137137

138138
## Read settings at the directory level
139139

140140
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."
141141

142-
```powershell
143-
(Get-AzureADDirectorySetting).Values | Where-Object -Property Name -Value UsageGuidelinesUrl -EQ
144-
```
142+
```powershell
143+
(Get-AzureADDirectorySetting).Values | Where-Object -Property Name -Value UsageGuidelinesUrl -EQ
144+
```
145145
These steps read settings at directory level, which apply to all Office groups in the directory.
146146

147147
1. Read all existing directory settings:
@@ -184,11 +184,11 @@ These steps read settings at directory level, which apply to all Office groups i
184184

185185
## Remove settings at the directory level
186186
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-
```
187+
```powershell
188+
Remove-AzureADDirectorySetting –Id c391b57d-5783-4c53-9236-cefb5c6ef323c
189+
```
190190

191-
## Update settings for a specific group
191+
## Create settings for a specific group
192192

193193
1. Search for the settings template named "Groups.Unified.Guest"
194194
```powershell
@@ -215,13 +215,49 @@ This step removes settings at directory level, which apply to all Office groups
215215
```powershell
216216
$SettingCopy["AllowToAddGuests"]=$False
217217
```
218-
5. Create the new setting for the required group in the directory:
218+
5. Get the ID of the group you want to apply this setting to:
219+
```powershell
220+
$groupID= (Get-AzureADGroup -SearchString "YourGroupName").ObjectId
221+
```
222+
6. Create the new setting for the required group in the directory:
223+
```powershell
224+
New-AzureADObjectSetting -TargetType Groups -TargetObjectId $groupID -DirectorySetting $SettingCopy
225+
```
226+
7. To verify the settings, run this command:
227+
```powershell
228+
Get-AzureADObjectSetting -TargetObjectId $groupID -TargetType Groups | fl Values
229+
```
230+
231+
## Update settings for a specific group
232+
1. Get the ID of the group whose setting you want to update:
233+
```powershell
234+
$groupID= (Get-AzureADGroup -SearchString "YourGroupName").ObjectId
235+
```
236+
2. Retrieve the setting of the group:
237+
```powershell
238+
$Setting = Get-AzureADObjectSetting -TargetObjectId $groupID -TargetType Groups
239+
```
240+
3. Update the setting of the group as you need, e.g.
241+
```powershell
242+
$Setting["AllowToAddGuests"] = $True
243+
```
244+
4. Then get the ID of the setting for this specific group:
245+
```powershell
246+
Get-AzureADObjectSetting -TargetObjectId $groupID -TargetType Groups
247+
```
248+
You will get a response similar to this:
249+
```powershell
250+
Id DisplayName TemplateId Values
251+
-- ----------- ----------- ----------
252+
2dbee4ca-c3b6-4f0d-9610-d15569639e1a Group.Unified.Guest 08d542b9-071f-4e16-94b0-74abb372e3d9 {class SettingValue {...
253+
```
254+
5. Then you can set the new value for this setting:
219255
```powershell
220-
New-AzureADObjectSetting -TargetType Groups -TargetObjectId ab6a3887-776a-4db7-9da4-ea2b0d63c504 -DirectorySetting $SettingCopy
256+
Set-AzureADObjectSetting -TargetType Groups -TargetObjectId $groupID -Id 2dbee4ca-c3b6-4f0d-9610-d15569639e1a -DirectorySetting $Setting
221257
```
222-
6. To verify the settings, run this command:
258+
6. You can read the value of the setting to make sure it has been updated correctly:
223259
```powershell
224-
Get-AzureADObjectSetting -TargetObjectId ab6a3887-776a-4db7-9da4-ea2b0d63c504 -TargetType Groups | fl Values
260+
Get-AzureADObjectSetting -TargetObjectId $groupID -TargetType Groups | fl Values
225261
```
226262

227263
## Cmdlet syntax reference

0 commit comments

Comments
 (0)