Skip to content

Commit 5d18d0b

Browse files
authored
Replace PowerShell methods that don't work
Replacing PowerShell methods that are not working. Updating with working commands using future proof official MS Graph SDK for PowerShell
1 parent b2d6133 commit 5d18d0b

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This article walks you through the options for modifying the default behaviors o
2828

2929
If the original version of group writeback is already enabled and in use in your environment, all your Microsoft 365 groups have already been written back to Active Directory. Instead of disabling all Microsoft 365 groups, review any use of the previously written-back groups. Disable only those that are no longer needed in on-premises Active Directory.
3030

31-
### Disable automatic writeback of all Microsoft 365 groups
31+
### Disable automatic writeback of new Microsoft 365 groups
3232

3333
To configure directory settings to disable automatic writeback of newly created Microsoft 365 groups, use one of these methods:
3434

@@ -45,13 +45,34 @@ To configure directory settings to disable automatic writeback of newly created
4545

4646
- Microsoft Graph: Use the [directorySetting](/graph/api/resources/directorysetting?view=graph-rest-beta&preserve-view=true) resource type.
4747

48-
### Disable writeback for each existing Microsoft 365 group
48+
### Disable writeback for all existing Microsoft 365 group
49+
50+
To disable writeback of all Microsoft 365 groups that were created before these modifications, use one of the folowing methods:
4951

5052
- Portal: Use the [Microsoft Entra admin portal](../enterprise-users/groups-write-back-portal.md).
51-
- PowerShell: Use the [Microsoft Identity Tools PowerShell module](https://www.powershellgallery.com/packages/MSIdentityTools/2.0.16). For example:
53+
- PowerShell: Use the [Microsoft Graph PowerShell SDK](https://learn.microsoft.com/en-us/powershell/microsoftgraph/installation?view=graph-powershell-1.0). For example:
54+
55+
```PowerShell
56+
#Import-module
57+
Import-module Microsoft.Graph
58+
59+
#Connect to MgGraph and select the Beta API Version
60+
Connect-MgGraph -Scopes Group.ReadWrite.All
61+
Select-MgProfile -Name beta
62+
63+
#List all Microsoft 365 Groups
64+
$Groups = Get-MgGroup -All | Where-Object {$_.GroupTypes -like "*unified*"}
65+
66+
#Disable Microsoft 365 Groups
67+
Foreach ($group in $Groups)
68+
{
69+
Update-MgGroup -GroupId $group.id -WritebackConfiguration @{isEnabled=$false}
70+
}
71+
```
72+
> [!Note]
73+
> We recomend using Microsoft Graph PowerShell SDK with [Windows PowerShell 7](https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.3)
5274
53-
`Get-mggroup -filter "groupTypes/any(c:c eq 'Unified')" | Update-MsIdGroupWritebackConfiguration -WriteBackEnabled $false`
54-
- Microsoft Graph: Use a [group object](/graph/api/group-update?tabs=http&view=graph-rest-beta&preserve-view=true).
75+
- Microsoft Graph Explorer: Use a [group object](/graph/api/group-update?tabs=http&view=graph-rest-beta&preserve-view=true).
5576

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

0 commit comments

Comments
 (0)