Skip to content
Menu

Is Microsoft Defender Actually Protecting This PC - End-to-End Health

Checks Defender end to end: antivirus on, real-time and tamper protection, signature age and last scan. Names the active antivirus when Defender is passive.

Is Microsoft Defender actually protecting this PC - end-to-end health is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Is Microsoft Defender actually protecting this PC - end-to-end health. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1; Microsoft Defender; administrator rights
Read-onlyReads, changes nothing

What It Does

The script reads Defender's own status and preferences and writes one row per check: antivirus enabled, real-time protection on, tamper protection on, signature age against MaxSignatureAgeHours, and time since the last quick or full scan against MaxScanAgeDays. The engine and platform versions are shown but never alerted on.

When another antivirus is active, Defender runs in passive mode or not at all. On a workstation the script then reads Windows Security Center, names the product that is protecting the PC and checks its signatures are up to date, and skips the Defender-only checks. No active antivirus, or one with old signatures, is an alert.

Windows Security Center does not exist on servers, so a server where Defender is passive is reported but not alerted on. A PC without Defender installed is skipped.

Before You Run It

  • Set MaxScanAgeDays to match your scan schedule, or set it to 0 to turn the scan check off.
  • Tamper protection is reported, but it only alerts on workstations when RequireTamperProtection is on.
  • If you run another antivirus, read its row rather than Defender's. That is the product protecting the PC.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 15 seconds.
  • Example answer: "Defender on: real-time on, signatures 6 h old, last scan 2 days ago"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • MaxSignatureAgeHours: Alert when the antivirus signatures are older than this many hours. Whole number, 0 to 87600. Default 48. 0 alerts on any age (useful for testing).
  • MaxScanAgeDays: Alert when the newest quick or full scan is older than this many days, or no scan is recorded. Whole number, 0 to 3650. Default 14. 0 turns the scan check off.
  • RequireTamperProtection: Alert when tamper protection is off. true or false. Default true. Applies to workstations only; Windows Server before 2022 has no tamper protection.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-defender-health.ps1 · 915 lines · 47.4 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.