Skip to content

Configuring Windows Defender

💡
Before you start

Python 3 and a terminal. Steps 1–4 run on Linux, macOS or Windows — nothing in them is Windows-specific, and nothing is installed.

🔴 No malware is involved and nothing is downloaded. The stand-in “sample” is three lines of plain English. Do not substitute a real malicious file: you do not need one to see the point, and your own antivirus will quite rightly intervene.

Step 5 needs Windows and administrator rights. It is the only step that leaves the terminal.

What is Windows Defender?

Windows Defender, officially known as Microsoft Defender Antivirus, is the built-in security solution that comes pre-installed with Windows 10 and Windows 11. It provides real-time protection against viruses, malware, spyware, and other threats without requiring any additional software or subscriptions.

Unlike third-party antivirus programs, Defender is deeply integrated into the operating system. It receives updates through Windows Update, runs with minimal performance impact, and is maintained by Microsoft's dedicated security research team. For most users, it provides all the protection needed when properly configured.

i
Defender vs. third-party antivirus

Independent testing labs like AV-TEST and AV-Comparatives consistently rate Windows Defender alongside premium paid solutions. Unless you have specific enterprise requirements, Defender is a strong choice for personal and small office use.

Verifying Defender is Active

Before configuring anything, you should confirm that Windows Defender is actually running on your system. Third-party antivirus software can disable Defender automatically during installation, so it is important to verify.

Method 1: Windows Security App

1
Open Windows Security. Click the Start menu and type Windows Security, then click the app from the search results. Alternatively, click the shield icon in the system tray (bottom-right corner of the taskbar).
2
Check the home screen. The Windows Security dashboard shows the status of all protection areas. Look for Virus & threat protection — it should display a green checkmark with "No action needed."
3
Click "Virus & threat protection." On this page, you should see "Microsoft Defender Antivirus is on" under the Current threats section. If it says another antivirus is active, Defender is running in passive mode.

Method 2: PowerShell Verification

For a quick command-line check, open PowerShell as Administrator and run:

Get-MpComputerStatus | Select-Object AntivirusEnabled, RealTimeProtectionEnabled, AMServiceEnabled

All three values should return True. If AntivirusEnabled shows False, another antivirus product has taken over and Defender is in passive mode.

!
Do not run two active antivirus programs.

Running multiple real-time antivirus engines simultaneously causes performance degradation, false positives, and can actually reduce your security. If you install a third-party antivirus, let it disable Defender automatically. If you want to switch back to Defender, uninstall the third-party product first.

Running Scans

Windows Defender offers several scan types, each suited to different situations. Understanding when to use each type helps you maintain thorough protection without wasting time on unnecessary full system scans.

Quick Scan

A Quick Scan checks the areas where malware is most commonly found: running processes, the Windows registry, common startup folders, and the system directories. It typically completes in 5 to 15 minutes and is sufficient for routine daily checks.

1
Open Windows Security and navigate to Virus & threat protection.
2
Click Quick scan. The scan begins immediately and you can continue using your computer while it runs.

From PowerShell (as Administrator):

Start-MpScan -ScanType QuickScan

Full Scan

A Full Scan examines every file on every drive connected to your computer. This includes external USB drives and mapped network shares. It can take anywhere from one to several hours depending on the amount of data on your system.

Use a Full Scan when:

  • You suspect your computer is infected despite a clean Quick Scan result
  • You have just removed malware and want to verify the system is clean
  • You have not run a full scan in over a month
  • You have connected an external drive from an untrusted source

To start a Full Scan, go to Virus & threat protection, click Scan options, select Full scan, and click Scan now.

Start-MpScan -ScanType FullScan

Custom Scan

A Custom Scan lets you target specific files or folders. This is useful when you want to scan a downloaded file, a USB drive, or a particular directory without scanning the entire system.

To run a Custom Scan from PowerShell on a specific path:

Start-MpScan -ScanType CustomScan -ScanPath "D:\Downloads"

Microsoft Defender Offline Scan

The Offline Scan restarts your computer into a minimal recovery environment and scans before Windows fully loads. This is effective against rootkits and other threats that can hide from scans while the operating system is running.

!
Save your work before running an Offline Scan.

Your computer will restart immediately. The scan takes approximately 15 minutes, and the computer will restart again when finished. Make sure all unsaved work is saved and all important applications are closed.

Start-MpWDOScan

Updating Virus Definitions

Virus definitions (also called security intelligence) are the database that Defender uses to identify known threats. Microsoft releases definition updates multiple times per day. Keeping definitions current is one of the most important things you can do for your security.

Automatic Updates

By default, Windows Defender downloads definition updates automatically through Windows Update. As long as your computer is connected to the internet and Windows Update is not paused, definitions should stay current without any action on your part.

Manual Update

If you want to force an immediate update (for example, before running a scan), you can trigger it manually:

1
Open Windows Security and go to Virus & threat protection.
2
Scroll down to Virus & threat protection updates and click Protection updates.
3
Click Check for updates. Windows will download and install the latest definitions.

From PowerShell:

Update-MpSignature

To check when definitions were last updated:

Get-MpComputerStatus | Select-Object AntivirusSignatureLastUpdated, AntivirusSignatureVersion
i
Definitions age matters.

If your definitions are more than two days old, your protection is significantly reduced. New malware variants are discovered constantly, and old definitions cannot detect them. If automatic updates are not working, investigate your Windows Update settings immediately.

Configuring Real-Time Protection

Real-time protection is the core feature of Windows Defender. It monitors file system activity, network connections, and process behavior continuously, intercepting threats as they appear rather than waiting for a scheduled scan to find them.

Verifying Real-Time Protection

1
Open Windows Security and go to Virus & threat protection.
2
Click Manage settings under Virus & threat protection settings.
3
Confirm that Real-time protection is toggled On. This page also shows Cloud-delivered protection, Automatic sample submission, and Tamper Protection.

Recommended Settings

Real-time protection On — Monitors files as they are opened, downloaded, or executed.
Cloud-delivered protection On — Sends suspicious file metadata to Microsoft for rapid analysis against a cloud database of known threats.
Automatic sample submission On — Automatically sends suspicious files to Microsoft for analysis. Disable if you handle sensitive or confidential files and do not want them uploaded.
Tamper Protection On — Prevents malware from disabling Defender through registry edits or command-line manipulation. Always keep this enabled.
!
Never disable real-time protection permanently.

If you temporarily disable it (for example, to install software that triggers a false positive), Windows will automatically re-enable it after a short period. If real-time protection stays off, your computer is exposed to every threat it encounters.

Managing Exclusions

Exclusions tell Defender to skip certain files, folders, file types, or processes during scans and real-time monitoring. This is useful for development environments, virtual machines, or applications that Defender incorrectly flags as threats.

Adding an Exclusion

1
Open Windows Security > Virus & threat protection > Manage settings.
2
Scroll down to Exclusions and click Add or remove exclusions.
3
Click Add an exclusion and choose the type: File, Folder, File type, or Process.

Common exclusion scenarios:

  • Development folders: Exclude project build directories (e.g., node_modules, target, .cargo) to improve build performance.
  • Virtual machines: Exclude VM disk files (.vhd, .vhdx, .vmdk) to avoid scan overhead.
  • Trusted applications: Exclude processes for software you trust that triggers false positives.

To add an exclusion via PowerShell:

# Exclude a folder
Add-MpPreference -ExclusionPath "C:\Projects\my-app"

# Exclude a file type
Add-MpPreference -ExclusionExtension ".vmdk"

# Exclude a process
Add-MpPreference -ExclusionProcess "myapp.exe"

# View current exclusions
Get-MpPreference | Select-Object ExclusionPath, ExclusionExtension, ExclusionProcess
!
Exclusions create blind spots.

Every exclusion is a location or process that Defender will never inspect. Malware authors know this and may target common exclusion paths. Only exclude what is strictly necessary, and review your exclusions periodically to remove entries you no longer need.

Scheduling Scans

While real-time protection catches threats as they appear, periodic scheduled scans provide an additional layer of assurance by checking files that may have been missed or that existed before a definition update was applied.

Using Task Scheduler

Windows Defender uses Task Scheduler for its scan schedules. You can customize when and how scans run:

1
Open Task Scheduler by pressing Win + R, typing taskschd.msc, and pressing Enter.
2
Navigate to Task Scheduler Library > Microsoft > Windows > Windows Defender.
3
Double-click Windows Defender Scheduled Scan. Go to the Triggers tab to set the schedule (daily, weekly, or at specific times). The Conditions tab lets you configure whether the scan runs on battery power or only when idle.

PowerShell Scan Scheduling

You can configure the scheduled scan type and day using PowerShell:

# Set scan to run every Sunday at 2:00 AM
Set-MpPreference -ScanScheduleQuickScanTime 02:00:00

# Set the scheduled scan day (0=Everyday, 1=Sunday, 2=Monday, ..., 7=Saturday)
Set-MpPreference -ScanScheduleDay 1

# Set scan type (1=Quick, 2=Full)
Set-MpPreference -ScanParameters 2

# Check current schedule
Get-MpPreference | Select-Object ScanScheduleDay, ScanScheduleQuickScanTime, ScanParameters
i
Recommended schedule.

A weekly Quick Scan is sufficient for most users with real-time protection enabled. Schedule a Full Scan monthly. Set scans to run during off-hours (e.g., 2:00 AM or during lunch) to minimize performance impact during work.

Now Do It Yourself: Break a Signature Scanner in One Character

The page above tells you to keep definitions updated. That is good advice built on an assumption worth testing: that a definition list is what catches malware. In twenty minutes you can build a working scanner, watch a single capital letter walk straight past it, and see why Defender needs the other layers it ships with.

You need Python 3. Nothing malicious is created or downloaded — the “sample” is three lines of ordinary English that does nothing at all. Steps 1–4 were run on Linux to produce every output below; step 5 is Windows and is marked where it could not be.

1
Make a file and take its fingerprint

Go: a terminal — Linux, macOS, or PowerShell on Windows. mkdir avlab then cd avlab.

Do: create a completely harmless text file that will stand in for a malicious one, and take its SHA-256 hash:

printf 'This file stands in for a piece of malware.\nIt does nothing at all - it is ordinary text.\nWhat matters is its exact bytes.\n' > sample.txt
sha256sum sample.txt

You should see: the file's fingerprint — 64 characters derived from its exact contents:

084c702bc4201052d95ad64bbf867345c2b0f2382bc450f312bfc7245fb49a24  sample.txt

Nothing here is malicious — it is three lines of English. On Windows PowerShell use Get-FileHash sample.txt, which prints the same value in capitals.

This hash is what a virus signature is: not a description of what the file does, but a fingerprint of exactly what it is.

If not: sha256sum: command not found on macOS — use shasum -a 256 sample.txt. If your hash differs from the one above, printf added or dropped a newline; that is fine, use your own value everywhere below.

2
Build a scanner that knows that one signature

Go: the same folder.

Do: save this as scanner.py. It carries a tiny signature database and a second kind of rule you will use in step 4:

import hashlib, sys, pathlib

# A signature database: exact file hashes known to be bad. This is how the earliest
# antivirus worked, and it is still one layer of how modern ones work.
KNOWN_BAD = {
    "084c702bc4201052d95ad64bbf867345c2b0f2382bc450f312bfc7245fb49a24": "Sample.Test.A",
}

# A behavioural rule: not the file's identity, but something about what it contains.
SUSPICIOUS_PATTERNS = [
    (b"stands in for a piece of", "Sample.Test.Generic"),
]

for name in sys.argv[1:]:
    data = pathlib.Path(name).read_bytes()
    digest = hashlib.sha256(data).hexdigest()

    hit = KNOWN_BAD.get(digest)
    if hit:
        print(f"{name:<14} SIGNATURE MATCH   {hit}")
        continue

    for pattern, label in SUSPICIOUS_PATTERNS:
        if pattern in data:
            print(f"{name:<14} PATTERN MATCH     {label}  (hash unknown: {digest[:12]}…)")
            break
    else:
        print(f"{name:<14} clean             (hash {digest[:12]}…)")

For now, strip out that second rule so the scanner works on signatures alone, then scan the file:

sed '/stands in for a piece of/d' scanner.py > scanner_hashonly.py
python3 scanner_hashonly.py sample.txt

You should see: a clean hit:

sample.txt     SIGNATURE MATCH   Sample.Test.A

That is antivirus in its simplest form, and it works perfectly — against a file that has not changed by a single byte.

If not: if it says clean, your hash from step 1 differs from the one in KNOWN_BAD. Paste your own hash into that dictionary, replacing the value there.

3
Defeat it with one capital letter

Go: the same folder.

Do: make a copy that differs by a single character — a lowercase m becomes a capital M — then scan both:

sed 's/a piece of malware/a piece of Malware/' sample.txt > sample2.txt
sha256sum sample.txt sample2.txt
python3 scanner_hashonly.py sample.txt sample2.txt

You should see: two hashes sharing nothing, and a scanner that only catches one of them:

084c702bc4201052d95ad64bbf867345c2b0f2382bc450f312bfc7245fb49a24  sample.txt
f5dfa285163c7e531fc2a19bca6f8fe0bbef7a3e26687c92232c3e81588087b4  sample2.txt
sample.txt     SIGNATURE MATCH   Sample.Test.A
sample2.txt    clean             (hash f5dfa285163c…)

🔴 The file does the same thing and the scanner calls it clean. This is why “my antivirus is up to date” guarantees so much less than it sounds like: a signature identifies one exact file, and changing anything at all — a byte, a filename embedded inside, a recompile — produces something the list has never seen. Attackers automate exactly this, generating thousands of variants that are functionally identical and individually unknown.

If not: if both files have the same hash, the sed found nothing to replace — run diff sample.txt sample2.txt; it should show one differing line.

4
Detect what the file DOES rather than what it is

Go: the same folder.

Do: run the full scanner — the one that kept the second rule, which looks for a characteristic pattern inside the file rather than its identity:

python3 scanner.py sample.txt sample2.txt

You should see: both files caught, the second by a rule that never knew its hash:

sample.txt     SIGNATURE MATCH   Sample.Test.A
sample2.txt    PATTERN MATCH     Sample.Test.Generic  (hash unknown: f5dfa285163c…)

That second line is the whole reason modern antivirus is more than a list. Microsoft Defender runs several layers at once: signatures for known files, heuristics and pattern matching for families of files, cloud-delivered protection that asks Microsoft about a file nobody has seen locally, and behaviour monitoring that watches what a program does after it starts.

Each catches what the others miss, and each has a cost — the pattern rule you just used would also flag any innocent file containing that phrase. That trade is what a false positive is, and it is why turning layers off to stop the noise is a worse idea than it looks.

If not: if sample2.txt still reports clean, you ran scanner_hashonly.py again — the full scanner is scanner.py, without the suffix.

5
Ask your own Defender which layers are on

Go: a Windows PowerShell window opened as Administrator.

Do: print the state of the engines you just modelled:

Get-MpComputerStatus | Select-Object AMServiceEnabled, RealTimeProtectionEnabled, BehaviorMonitorEnabled, AntivirusSignatureLastUpdated

You should see: four values. BehaviorMonitorEnabled is the one matching step 4 — it is what still helps when a file's hash is unknown, and it is commonly the first thing switched off to make a warning go away.

Not re-run for this page: PowerShell is Windows-only and this page was written on Linux. The command is from Microsoft's documented Defender module. Steps 1–4 were run, and they are what the reasoning rests on.

AntivirusSignatureLastUpdated deserves a second look now. A recent date means your signature list is current — step 3 showed exactly how much that is worth on its own.

If not: Get-MpComputerStatus is not recognized means you are in Command Prompt rather than PowerShell, or a third-party antivirus has replaced Defender — in which case Defender is genuinely disabled and its status is not the one that matters.

🎉
Check yourself before moving on

A colleague says their machine is safe because Defender updated its definitions this morning. Using step 3, what have they actually established? Answer: That Defender recognises files someone has already seen and catalogued. It says nothing about a variant produced an hour ago, because changing one byte produces a hash the list has never contained. What covers that gap is the behaviour monitoring and cloud lookup from steps 4 and 5 — not the update date.

Now do it without the page: explain why an antivirus that never produces a false positive is probably not protecting you very well. If you can connect that to the pattern rule in step 4 catching an innocent file containing the same phrase, you understand the trade every scanner makes.

Summary

In this tutorial, you learned how to:

  • Verify that Windows Defender is active and running properly
  • Run different scan types (Quick, Full, Custom, and Offline) for different situations
  • Update virus definitions manually and verify they are current
  • Configure real-time protection settings for optimal security
  • Set up exclusions for development tools and virtual machines
  • Schedule automatic scans using Task Scheduler and PowerShell
+
Well done!

Your Windows Defender is now properly configured. In the next tutorial, you will learn about advanced Defender features including Controlled Folder Access, Exploit Protection, and Attack Surface Reduction rules that provide additional layers of defense.