<# .TITLE Windows Defender Definition Update Detection .SYNOPSIS Detects if Windows Defender antivirus definitions are outdated .DESCRIPTION Checks if Windows Defender definitions are current (within 48 hours). Returns exit code 1 if definitions are outdated. .TAGS Remediation,Detection .REMEDIATIONTYPE Detection .PAIRSCRIPT remediate-antivirus-definitions.ps1 .PLATFORM Windows .MINROLE Intune Service Administrator .PERMISSIONS DeviceManagementManagedDevices.ReadWrite.All .AUTHOR Ugur Koc .VERSION 1.0 .CHANGELOG 1.0 - Initial version .LASTUPDATE 2025-06-09 .EXAMPLE .\detect-antivirus-definitions-outdated.ps1 .NOTES Runs in SYSTEM context #> $ErrorActionPreference = "Stop" $script:MaxDefinitionAgeHours = 48 try { # Get Defender status $mpStatus = Get-MpComputerStatus -ErrorAction Stop # Check definition age $now = Get-Date $definitionAge = ($now - $mpStatus.AntivirusSignatureLastUpdated).TotalHours Write-Output "Definition age: $([math]::Round($definitionAge, 1)) hours" Write-Output "Last updated: $($mpStatus.AntivirusSignatureLastUpdated)" Write-Output "Version: $($mpStatus.AntivirusSignatureVersion)" if ($definitionAge -gt $script:MaxDefinitionAgeHours) { Write-Output "Definitions are outdated (threshold: $script:MaxDefinitionAgeHours hours)" exit 1 } Write-Output "Windows Defender definitions are up to date" exit 0 } catch { Write-Error "Detection failed: $_" exit 2 } # Copia sin cambios de https://github.com/ugurkocde/IntuneAutomation (commit 797bb2e). # MIT License # # Copyright (c) 2025 Ugur Koc | Microsoft MVP # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE.