Skip to content

Commit

Permalink
Merge pull request #4125 from swisscom/Fix_4124_EXOHostedContentFilte…
Browse files Browse the repository at this point in the history
…rPolicy

EXOHostedContentFilterPolicy - fix
  • Loading branch information
NikCharlebois authored Jan 9, 2024
2 parents e4f6c3e + 6882c8e commit 7adead2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* AADConditionalAccessPolicy
* FIXES [[#3885](https://github.com/microsoft/Microsoft365DSC/issues/3885)]

* EXOHostedContentFilterPolicy
* Fix issue on parameters AllowedSenders, AllowedSenderDomains, BlockedSenders, BlockSenderDomains if desired state is empty but current state is not empty
FIXES[#4124](https://github.com/microsoft/Microsoft365DSC/issues/4124)

# 1.24.103.1

* AADConditionalAccessPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,33 @@ function Get-TargetResource
}
else
{
$AllowedSendersValues = $HostedContentFilterPolicy.AllowedSenders.Sender | Select-Object Address -ExpandProperty Address
$BlockedSendersValues = $HostedContentFilterPolicy.BlockedSenders.Sender | Select-Object Address -ExpandProperty Address
[System.String[]]$AllowedSendersValues = $HostedContentFilterPolicy.AllowedSenders.Sender | Select-Object Address -ExpandProperty Address
[System.String[]]$BlockedSendersValues = $HostedContentFilterPolicy.BlockedSenders.Sender | Select-Object Address -ExpandProperty Address
# Check if the values are null and assign them an empty string array if they are
if ($null -eq $AllowedSendersValues) {
$AllowedSendersValues = @()
}
if ($null -eq $BlockedSendersValues) {
$BlockedSendersValues = @()
}

[System.String[]]$AllowedSenderDomains = $HostedContentFilterPolicy.AllowedSenderDomains.Domain
[System.String[]]$BlockedSenderDomains = $HostedContentFilterPolicy.BlockedSenderDomains.Domain
# Check if the values are null and assign them an empty string array if they are
if ($null -eq $AllowedSenderDomains) {
$AllowedSenderDomains = @()
}
if ($null -eq $BlockedSenderDomains) {
$BlockedSenderDomains = @()
}
$result = @{
Ensure = 'Present'
Identity = $Identity
AddXHeaderValue = $HostedContentFilterPolicy.AddXHeaderValue
AdminDisplayName = $HostedContentFilterPolicy.AdminDisplayName
AllowedSenderDomains = $HostedContentFilterPolicy.AllowedSenderDomains.Domain
AllowedSenderDomains = $AllowedSenderDomains
AllowedSenders = $AllowedSendersValues
BlockedSenderDomains = $HostedContentFilterPolicy.BlockedSenderDomains.Domain
BlockedSenderDomains = $BlockedSenderDomains
BlockedSenders = $BlockedSendersValues
BulkQuarantineTag = $HostedContentFilterPolicy.BulkQuarantineTag
BulkSpamAction = $HostedContentFilterPolicy.BulkSpamAction
Expand Down Expand Up @@ -1039,26 +1056,6 @@ function Test-TargetResource
$ValuesToCheck.Remove('CertificatePassword') | Out-Null
$ValuesToCheck.Remove('ManagedIdentity') | Out-Null

if ($null -ne $ValuesToCheck.AllowedSenders -and $ValuesToCheck.AllowedSenders.Length -eq 0)
{
$ValuesToCheck.AllowedSenders = $null
}

if ($null -ne $ValuesToCheck.AllowedSenderDomains -and $ValuesToCheck.AllowedSenderDomains.Length -eq 0)
{
$ValuesToCheck.AllowedSenderDomains = $null
}

if ($null -ne $ValuesToCheck.BlockedSenders -and $ValuesToCheck.BlockedSenders.Length -eq 0)
{
$ValuesToCheck.BlockedSenders = $null
}

if ($null -ne $ValuesToCheck.BlockedSenderDomains -and $ValuesToCheck.BlockedSenderDomains.Length -eq 0)
{
$ValuesToCheck.BlockedSenderDomains = $null
}

$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $ValuesToCheck `
Expand Down

0 comments on commit 7adead2

Please sign in to comment.