@@ -41,10 +41,15 @@ function Invoke-CIPPStandardsharingDomainRestriction {
4141 $StateIsCorrect = $CurrentState.sharingDomainRestrictionMode -eq ' none'
4242 } else {
4343 $SelectedDomains = [String []]$Settings.Domains.Split (' ,' ).Trim() ?? @ ()
44- $StateIsCorrect = ($CurrentState.sharingDomainRestrictionMode -eq $mode ) -and
45- ($mode -eq ' allowList' -and (! (Compare-Object - ReferenceObject $CurrentState.sharingAllowedDomainList - DifferenceObject $SelectedDomains ))) -or
46- ($mode -eq ' blockList' -and (! (Compare-Object - ReferenceObject $CurrentState.sharingBlockedDomainList - DifferenceObject $SelectedDomains )))
44+ $CurrentAllowedDomains = $CurrentState.sharingAllowedDomainList ?? @ ()
45+ $CurrentBlockedDomains = $CurrentState.sharingBlockedDomainList ?? @ ()
46+
47+ $StateIsCorrect = ($CurrentState.sharingDomainRestrictionMode -eq $mode ) -and (
48+ ($mode -eq ' allowList' -and ([string []]($CurrentAllowedDomains | Sort-Object ) -join ' ,' ) -eq ([string []]($SelectedDomains | Sort-Object ) -join ' ,' )) -or
49+ ($mode -eq ' blockList' -and ([string []]($CurrentBlockedDomains | Sort-Object ) -join ' ,' ) -eq ([string []]($SelectedDomains | Sort-Object ) -join ' ,' ))
50+ )
4751 }
52+ Write-Host " StateIsCorrect: $StateIsCorrect "
4853
4954 if ($Settings.remediate -eq $true ) {
5055 if ($StateIsCorrect -eq $true ) {
@@ -61,14 +66,15 @@ function Invoke-CIPPStandardsharingDomainRestriction {
6166 }
6267
6368 $cmdParams = @ {
64- tenantid = $tenant
65- uri = ' https://graph.microsoft.com/beta/admin/sharepoint/settings'
66- AsApp = $true
67- Type = ' PATCH'
68- Body = ($Body | ConvertTo-Json )
69- ContentType = ' application/json'
69+ tenantid = $tenant
70+ uri = ' https://graph.microsoft.com/beta/admin/sharepoint/settings'
71+ AsApp = $true
72+ Type = ' PATCH'
73+ body = ($Body | ConvertTo-Json )
7074 }
7175
76+ Write-Host ($cmdParams | ConvertTo-Json - Depth 5 )
77+
7278 try {
7379 $null = New-GraphPostRequest @cmdParams
7480 Write-LogMessage - API ' Standards' - tenant $tenant - message ' Successfully updated Sharing Domain Restriction settings' - sev Info
0 commit comments