From fee8d250c9fa341aedf7798e0995278e72ac1406 Mon Sep 17 00:00:00 2001
From: Ricardo Mestre <ricardo.mestre@fujitsu.com>
Date: Wed, 6 Dec 2023 14:11:58 +0000
Subject: [PATCH] Fix condition in Test-TargetResource

---
 CHANGELOG.md                                                  | 3 +++
 .../MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1    | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index a26485cac1..8847d03ed2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
 
 # UNRELEASED
 
+* IntuneAntivirusPolicyWindows10SettingCatalog
+  * Fix condition in Test-TargetResource to check if resource was removed or not
+  FIXES [#3958](https://github.com/microsoft/Microsoft365DSC/issues/3958)
 * DEPENDENCIES
   * Updated MSCloudLoginAssistant to version 1.1.2.
 * MISC
diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1
index 76d31bcbf7..4e12202bf3 100644
--- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1
+++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1
@@ -1286,9 +1286,9 @@ function Test-TargetResource
     $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone()
     $ValuesToCheck.Remove('Identity') | Out-Null
 
-    if ($CurrentValues.Ensure -eq 'Absent')
+    if ($CurrentValues.Ensure -ne $PSBoundParameters.Ensure)
     {
-        Write-Verbose -Message 'The policy was not found'
+        Write-Verbose -Message "Test-TargetResource returned $false"
         return $false
     }
     $testResult = $true