Skip to content

Commit 1393178

Browse files
committed
fix(standards): avoid empty array compare errors
Replace `Compare-Object` checks with sorted string equality for Teams federation allowed/blocked domain matching. This prevents parameter binding failures when one side is an empty array while preserving exact list-match behavior.
1 parent e2903f9 commit 1393178

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Modules/CIPPStandards/Public/Standards/Invoke-CIPPStandardTeamsFederationConfiguration.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,15 @@ function Invoke-CIPPStandardTeamsFederationConfiguration {
123123
$BlockedDomainsMatches = $true
124124
}
125125
'AllowSpecificExternal' {
126-
$AllowedDomainsMatches = -not (Compare-Object -ReferenceObject $AllowedDomainsAsAList -DifferenceObject $CurrentAllowedDomains)
126+
# Both lists are already Sort-Object'd; compare as joined strings. Avoids Compare-Object,
127+
# whose parameter binder coerces an empty array @() to $null and then throws.
128+
$AllowedDomainsMatches = (@($AllowedDomainsAsAList) -join ',') -eq (@($CurrentAllowedDomains) -join ',')
127129
$BlockedDomainsMatches = (!$CurrentBlockedDomains -or @($CurrentBlockedDomains).Count -eq 0)
128130
}
129131
'BlockSpecificExternal' {
130132
# Allowed should be AllowAllKnownDomains, blocked domains already parsed above
131133
$AllowedDomainsMatches = $IsCurrentAllowAllKnownDomains
132-
$BlockedDomainsMatches = -not (Compare-Object -ReferenceObject $BlockedDomains -DifferenceObject $CurrentBlockedDomains)
134+
$BlockedDomainsMatches = (@($BlockedDomains) -join ',') -eq (@($CurrentBlockedDomains) -join ',')
133135
}
134136
}
135137

0 commit comments

Comments
 (0)