Skip to content

Commit

Permalink
fix issue with disableM365 groupusers
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Jul 27, 2023
1 parent f0278ee commit 32b479c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Standards_DisableM365GroupUsers/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ param($tenant)

try {
$CurrentState = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/settings" -tenantid $tenant) | Where-Object -Property displayname -EQ 'Group.unified'
if (!$CurrentState) {
#if no current configuration is found, we set it to the default template supplied by MS.
$CurrentState = '{"id":"","displayName":"Group.Unified","templateId":"62375ab9-6b52-47ed-826b-58e47e0e304b","values":[{"name":"NewUnifiedGroupWritebackDefault","value":"true"},{"name":"EnableMIPLabels","value":"false"},{"name":"CustomBlockedWordsList","value":""},{"name":"EnableMSStandardBlockedWords","value":"false"},{"name":"ClassificationDescriptions","value":""},{"name":"DefaultClassification","value":""},{"name":"PrefixSuffixNamingRequirement","value":""},{"name":"AllowGuestsToBeGroupOwner","value":"false"},{"name":"AllowGuestsToAccessGroups","value":"true"},{"name":"GuestUsageGuidelinesUrl","value":""},{"name":"GroupCreationAllowedGroupId","value":""},{"name":"AllowToAddGuests","value":"true"},{"name":"UsageGuidelinesUrl","value":""},{"name":"ClassificationList","value":""},{"name":"EnableGroupCreation","value":"true"}]}'
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/settings/$($CurrentState.id)" -Type POST -Body $CurrentState -ContentType "application/json")
$CurrentState = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/settings" -tenantid $tenant) | Where-Object -Property displayname -EQ 'Group.unified'
}
($CurrentState.values | Where-Object { $_.name -eq 'EnableGroupCreation' }).value = "false"
$body = "{values : $($CurrentState.values | ConvertTo-Json -Compress)}"
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/settings/$($CurrentState.id)" -Type patch -Body $body -ContentType "application/json")
Expand Down

0 comments on commit 32b479c

Please sign in to comment.