My Windows Defender Log Analyzer is a comprehensive PowerShell script designed to automate the collection, extraction, and analysis of Windows Defender logs. This powerful tool helps system administrators and security professionals quickly identify potential security issues, scan anomalies, and performance problems within their Windows Defender installations.
Key Features
Automated Log Collection
- Executes the Windows Defender diagnostic tool (MpCmdRun -getfiles)
- Automatically locates and extracts the generated diagnostic files
- Uses multiple extraction methods to ensure compatibility across different Windows environments
Comprehensive Log Analysis
- Scans through all Windows Defender log files systematically
- Detects errors, warnings, and critical issues
- Identifies abnormal scan patterns and unscheduled scans
- Analyzes both text logs and Windows event logs (.evtx files)
Detailed Reporting
- Creates separate log files for different types of issues:
Error details log
Warning details log
Critical issues log
Scan activity log
Generates a concise summary report with actionable recommendations - Provides counts of different issue types for quick assessment
System Status Check
- Retrieves the current Windows Defender configuration
- Checks for outdated virus definitions
- Verifies real-time protection status
- Reviews recent scan history and scheduled scan configuration
The Windows Defender Log Analyzer script operates through a series of logical steps, each building on the previous one to create a comprehensive analysis system:
- Initialization Phase
- The script creates a dedicated output directory in the same location where it's run
- It establishes log files for tracking the analysis process and findings
- All paths and variables are set up to ensure proper operation across different systems
- Log Collection Phase
- The script locates and executes the MpCmdRun.exe utility with the -getfiles parameter
- This command instructs Windows Defender to compile its diagnostic information
- The script monitors the process to ensure successful completion
- The result is a CAB file containing compressed Windows Defender logs
- Extraction Phase
- The script searches for the generated CAB file, typically in the Windows Defender Support directory
- It implements multiple extraction methods (expand.exe, COM object, and 7-Zip if available)
- These fallback mechanisms ensure the script works across different Windows environments
- The logs are extracted to an organized folder structure for analysis
- Analysis Phase
- The script systematically examines each extracted log file through specialized functions:
- Text logs are processed with pattern matching to identify issues
- Event logs (.evtx) are analyzed using Get-WinEvent for structured data extraction
- Current Windows Defender status is retrieved using PowerShell cmdlets
- During analysis, the script tracks:
- Error counts and detailed error messages
- Warning and critical issue identification
- Scan patterns, including abnormal or interrupted scans
- Unscheduled security operations
- The script systematically examines each extracted log file through specialized functions:
- Classification Phase
- As issues are identified, they're categorized by severity and type
- Each issue is recorded in dedicated log files for easy review:
- Errors go to DefenderErrorDetails.log
- Warnings go to DefenderWarningDetails.log
- Critical issues go to DefenderCriticalDetails.log
- Scan information goes to DefenderScanDetails.log
- Reporting Phase
- The script generates a concise summary report (DefenderQuickSummary.txt)
- The summary includes counts of issues found and links to detailed logs
- Custom recommendations are provided based on the specific issues detected
- Output includes paths to all log files and extracted data for further investigation
Information flows through the script in a consistent manner:
- Raw logs are collected from Windows Defender →
- Logs are extracted and organized →
- Pattern matching and event analysis extract relevant data →
- Issues are categorized and recorded in specific log files →
- Statistical analysis creates summary information →
- Recommendations are generated based on findings →
- User-friendly reports are created for review
This logical approach transforms complex, scattered log data into organized, actionable security intelligence that helps maintain Windows Defender's effectiveness and overall system security.
These are some screenshots of the script running, this is the initial stage:
Then we move on to the next two phases as below:
Then we move on to step 4 and 5 as below:
URGENT: Review the 163 critical issues found in the logs
C:\Quarantine\DefenderLogAnalyser\DefenderLogsAnalysis\DefenderCriticalDetails.log)