diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f0e3b0325..a4a359f60c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * All resources * Applying project default formatting on all files, to improve reading and troubleshooting +* EXOTransportRule + * Fixed conditional logic for creation and update. * IntuneTrustedRootCertificateIOS * Initial release * M365DSCDRGUtil diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 index ef40b3be26..d2c511a0ef 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 @@ -1797,6 +1797,20 @@ function Set-TargetResource if ($Ensure -eq 'Present' -and $currentTransportRuleConfig.Ensure -eq 'Absent') { Write-Verbose -Message "Transport Rule '$($Name)' does not exist but it should. Create and configure it." + + $nullKeysToRemove = @() + foreach ($key in $NewTransportRuleParams.Keys) + { + if ($NewTransportRuleParams.$key.GetType().Name -eq 'String[]' -and $NewTransportRuleParams.$key.Length -eq 0) + { + $nullKeysToRemove += $key + } + } + foreach ($paramToRemove in $nullKeysToRemove) + { + $NewTransportRuleParams.Remove($paramToRemove) | Out-Null + } + # Create Transport Rule New-TransportRule @NewTransportRuleParams @@ -1809,7 +1823,34 @@ function Set-TargetResource } # CASE: Transport Rule exists and it should, but has different values than the desired ones elseif ($Ensure -eq 'Present' -and $currentTransportRuleConfig.Ensure -eq 'Present') - { + { + if ($null -ne $HeaderContainsMessageHeader -and $null -eq $currentTransportRuleConfig.HeaderContainsMessageHeader) + { + $SetTransportRuleParams.Add("HeaderContainsMessageHeader",$null) + } + if ($null -ne $HeaderMatchesPatterns -and $null -eq $currentTransportRuleConfig.HeaderMatchesMessageHeader) + { + $SetTransportRuleParams.Add("HeaderMatchesMessageHeader",$null) + } + if ($null -ne $ExceptIfHeaderContainsWords -and $null -eq $currentTransportRuleConfig.ExceptIfHeaderContainsMessageHeader) + { + $SetTransportRuleParams.Add("ExceptIfHeaderContainsMessageHeader",$null) + } + if ($null -ne $ExceptIfHeaderMatchesPatterns -and $null -eq $currentTransportRuleConfig.ExceptIfHeaderMatchesMessageHeader) + { + $SetTransportRuleParams.Add("ExceptIfHeaderMatchesMessageHeader",$null) + } + if ($null -ne $ApplyOME) + { + Write-Warning -Message "ApplyOME is deprecated. Use ApplyRightsProtectionTemplate instead." + $SetTransportRuleParams.Remove("ApplyOME") | Out-Null + } + if ($null -ne $RemoveOME) + { + Write-Warning -Message "RemoveOME is deprecated. Use RemoveOMEv2 instead." + $SetTransportRuleParams.Remove("RemoveOME") | Out-Null + } + Write-Verbose -Message "Transport Rule '$($Name)' already exists, but needs updating." Write-Verbose -Message "Setting Transport Rule $($Name) with values: $(Convert-M365DscHashtableToString -Hashtable $SetTransportRuleParams)" Set-TransportRule @SetTransportRuleParams diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppProtectionPolicyAndroid/MSFT_IntuneAppProtectionPolicyAndroid.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppProtectionPolicyAndroid/MSFT_IntuneAppProtectionPolicyAndroid.psm1 index f2b2e9d031..f9b14c892d 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppProtectionPolicyAndroid/MSFT_IntuneAppProtectionPolicyAndroid.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppProtectionPolicyAndroid/MSFT_IntuneAppProtectionPolicyAndroid.psm1 @@ -350,14 +350,21 @@ function Get-TargetResource } catch { - New-M365DSCLogEntry -Message 'Error retrieving data:' ` - -Exception $_ ` - -Source $($MyInvocation.MyCommand.Source) ` - -TenantId $TenantId ` - -Credential $Credential - - $nullResult = Clear-M365DSCAuthenticationParameter -BoundParameters $nullResult - return $nullResult + if ($_.Exception.Message -eq 'Multiple Policies with same displayname identified - Module currently only functions with unique names') + { + throw $_ + } + else + { + New-M365DSCLogEntry -Message 'Error retrieving data:' ` + -Exception $_ ` + -Source $($MyInvocation.MyCommand.Source) ` + -TenantId $TenantId ` + -Credential $Credential + + $nullResult = Clear-M365DSCAuthenticationParameter -BoundParameters $nullResult + return $nullResult + } } }