Report available protection status and preferences; exclusions are explicit opt-in.
How to use it
.\Get-SocDefenderHealthReview.ps1
# Only where authorised and appropriate:
.\Get-SocDefenderHealthReview.ps1 -IncludeExclusions
Platform and permissions
Windows Defender cmdlets and appropriate read permissions; managed policies may hide information.
What changes / what is read
Reads status/preferences. No protection, exclusions, scans or sample submission settings are changed.
Scope and interpretation
Unavailable data is not a healthy result. Platform mode, policy and permissions affect fields. Exclusions and settings are sensitive; this is not a security certification.
Practice task
Explain what can and cannot be concluded if a status query fails or an exclusion field is hidden.
Reference
Microsoft documentation. Review the documentation for your installed version and use only an authorised learning or investigation environment.
This is personal educational material. Review the complete code and your signing policy before use. PowerShell code is displayed and downloaded as text; WordPress does not run it. Collection caps limit rows/files, not every provider’s wall-clock execution time.
#requires -Version 5.1
[CmdletBinding()]
param([switch]$IncludeExclusions)
if($env:OS -ne 'Windows_NT'){throw 'Windows Defender cmdlets are required.'}
$issues=New-Object 'System.Collections.Generic.List[string]';$status=$null;$settings=$null;$exclusions=$null
try {
$status=Get-MpComputerStatus -ErrorAction Stop | Select-Object AMServiceEnabled,AntivirusEnabled,AntispywareEnabled,RealTimeProtectionEnabled,BehaviorMonitorEnabled,NISEnabled,IsTamperProtected,AntivirusSignatureVersion,AntivirusSignatureLastUpdated,QuickScanAge,FullScanAge
} catch {$issues.Add('Computer status: '+$_.Exception.Message)}
try {
$preference=Get-MpPreference -ErrorAction Stop
$settings=$preference | Select-Object DisableRealtimeMonitoring,DisableBehaviorMonitoring,DisableIOAVProtection,PUAProtection,MAPSReporting,SubmitSamplesConsent
if($IncludeExclusions){$exclusions=$preference | Select-Object ExclusionPath,ExclusionProcess,ExclusionExtension,ExclusionIpAddress}
} catch {$issues.Add('Preferences: '+$_.Exception.Message)}
[pscustomobject]@{CollectedUtc=[datetime]::UtcNow;Status=$status;Preferences=$settings;Exclusions=$exclusions;ExclusionsRequested=[bool]$IncludeExclusions;Errors=$issues.ToArray();Note='Missing fields/data can reflect platform, role, policy or unavailable Defender components. This is a point-in-time report, not a health certification. Exclusions are sensitive and can be hidden by policy. No protection setting, exclusion, sample or scan is changed or submitted.'}
Example code is displayed as text. Review it and test in your own lab before use.