Skip to content

Commit 99d55a4

Browse files
authored
Merge pull request #103884 from riantu/patch-19
Update remaining PowerShell script
2 parents baae35e + 08fd214 commit 99d55a4

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

articles/active-directory/hybrid/how-to-connect-modify-group-writeback.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,38 @@ If the original version of group writeback is already enabled and in use in your
3333
To configure directory settings to disable automatic writeback of newly created Microsoft 365 groups, use one of these methods:
3434

3535
- Azure portal: Update the `NewUnifiedGroupWritebackDefault` setting to `false`.
36-
- PowerShell: Use the [New-AzureADDirectorySetting](../enterprise-users/groups-settings-cmdlets.md) cmdlet. For example:
36+
- PowerShell: Use the [Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/installation?view=graph-powershell-1.0&preserve-view=true). For example:
3737

3838
```PowerShell
39-
$TemplateId = (Get-AzureADDirectorySettingTemplate | where {$_.DisplayName -eq "Group.Unified" }).Id
40-
$Template = Get-AzureADDirectorySettingTemplate | where -Property Id -Value $TemplateId -EQ
41-
$Setting = $Template.CreateDirectorySetting()
42-
$Setting["NewUnifiedGroupWritebackDefault"] = "False"
43-
New-AzureADDirectorySetting -DirectorySetting $Setting
39+
# Import Module
40+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
41+
42+
#Connect to MgGraph with necessary scope and select the Beta API Version
43+
Connect-MgGraph -Scopes Directory.ReadWrite.All
44+
Select-MgProfile -Name beta
45+
46+
# Import "Group.Unified" template values to a hashtable
47+
$Template = Get-MgDirectorySettingTemplate | Where-Object {$_.DisplayName -eq "Group.Unified"}
48+
$TemplateValues = @{}
49+
$Template.Values | ForEach-Object {
50+
$TemplateValues.Add($_.Name, $_.DefaultValue)
51+
}
52+
53+
# Update the value for new unified group writeback default
54+
$TemplateValues["NewUnifiedGroupWritebackDefault"] = "false"
55+
# Create a directory setting using the Template values hashtable including the updated value
56+
$params = @{}
57+
$params.Add("TemplateId", $Template.Id)
58+
$params.Add("Values", @())
59+
$TemplateValues.Keys | ForEach-Object {
60+
$params.Values += @(@{Name = $_; Value = $TemplateValues[$_]})
61+
}
62+
New-MgDirectorySetting -BodyParameter $params
4463
```
4564

65+
> [!NOTE]
66+
> We recommend using Microsoft Graph PowerShell SDK with [Windows PowerShell 7](/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.3&preserve-view=true).
67+
4668
- Microsoft Graph: Use the [directorySetting](/graph/api/resources/directorysetting?view=graph-rest-beta&preserve-view=true) resource type.
4769

4870
### Disable writeback for all existing Microsoft 365 group
@@ -56,7 +78,7 @@ To disable writeback of all Microsoft 365 groups that were created before these
5678
#Import-module
5779
Import-module Microsoft.Graph
5880
59-
#Connect to MgGraph and select the Beta API Version
81+
#Connect to MgGraph with necessary scope and select the Beta API Version
6082
Connect-MgGraph -Scopes Group.ReadWrite.All
6183
Select-MgProfile -Name beta
6284
@@ -68,8 +90,8 @@ To disable writeback of all Microsoft 365 groups that were created before these
6890
{
6991
Update-MgGroup -GroupId $group.id -WritebackConfiguration @{isEnabled=$false}
7092
}
71-
> We recomend using Microsoft Graph PowerShell SDK with [Windows PowerShell 7](/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.3&preserve-view=true)
72-
93+
```
94+
7395
- Microsoft Graph Explorer: Use a [group object](/graph/api/group-update?tabs=http&view=graph-rest-beta&preserve-view=true).
7496

7597
## Delete groups when they're disabled for writeback or soft deleted

0 commit comments

Comments
 (0)