Windows Defender Definition Update
Checks if Windows Defender definitions are current (within 48 hours). Returns exit code 1 if definitions are outdated.
// QUALITY CHECKS
Validation status
Quality checks
All checks pass- ParsePass
- LintPass
- MetadataPass
- Runbook-readyPass
- Module depsPass
Tests run automatically on every change. What does each check mean?
// REQUIRED PERMISSIONS
Microsoft Graph scopes
DeviceManagementManagedDevices.ReadWrite.AllAllows the app to read and write the properties of devices managed by Microsoft Intune, without a signed-in user. Does not allow high impact operations such as remote wipe and password reset on the device's owner
// CHANGELOG
Version history
Entry · 01
1.0 - Initial version
// CODE
Source
<#
.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
}// NOTES
Author notes
Runs in SYSTEM context
// RELATED
Scripts that travel together.
Picked by shared tags, category, and script type — nothing magic, just metadata overlap.
Disk Cleanup Script
Checks Windows temp folders and recycle bin size. Returns exit code 1 if more than 1GB can be cleaned up.
RemediationLocal Admin Drift Script
Enumerates the local Administrators group and compares every member against an allowlist of approved accounts and well-known SIDs (built-in Administrator, the Entra-joined device admin roles, and configurable extra entries). Returns exit code 1 when unauthorized members are present, triggering the paired remediation that removes them. This catches technician accounts, self-elevation leftovers, and helpdesk additions that were never cleaned up.
RemediationOneDrive Known Folder Move Script
Checks the OneDrive policy registry keys for silent Known Folder Move opt-in (KFMSilentOptIn with the tenant ID) and verifies the OneDrive sync client is installed. Returns exit code 1 when the KFM policy is missing or points to a different tenant, triggering the paired remediation that writes the policy keys. Desktop, Documents, and Pictures then move to OneDrive automatically at the next OneDrive sign-in.
Remediation