Updates the definitions, reports the version it ended up with, runs a quick scan and then reads back only the detections from the last hour, so the output is what this scan found rather than the machine's whole history. Threat names and affected resources are logged for anything it hits.
powershell
# Run Microsoft Defender Quick Scan
# Single use case: trigger a quick scan and report the findings
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
if (-not (Get-Command Start-MpScan -ErrorAction SilentlyContinue)) {
Write-Log "Microsoft Defender cmdlets not available on this host."
return
}
Write-Log "Updating definitions..."
Update-MpSignature -ErrorAction SilentlyContinue
$status = Get-MpComputerStatus
Write-Log "Definitions version: $($status.AntivirusSignatureVersion) ($($status.AntivirusSignatureLastUpdated))"
Write-Log "Starting quick scan (this can take several minutes)..."
Start-MpScan -ScanType QuickScan
Write-Log "Quick scan finished."
$threats = Get-MpThreatDetection -ErrorAction SilentlyContinue
if ($threats) {
$recent = $threats | Where-Object { $_.InitialDetectionTime -gt (Get-Date).AddHours(-1) }
if ($recent) {
Write-Log "WARNING: $(@($recent).Count) threat(s) detected during this scan!"
foreach ($t in $recent) {
$threat = Get-MpThreat -ThreatID $t.ThreatID -ErrorAction SilentlyContinue
Write-Log "THREAT: $(if ($threat) { $threat.ThreatName } else { $t.ThreatID }) - resources: $($t.Resources -join '; ')"
}
return
}
}
Write-Log "No threats detected."Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Security & Auditing
Enable the Windows Firewall with PowerShell
2026-08-17Check Windows Firewall Status with PowerShell
2026-08-17Disable SMBv1 with PowerShell
2026-08-17Enforce TLS 1.2 in the Registry with PowerShell
2026-08-17Enable RDP Network Level Authentication with PowerShell
2026-08-17Audit the Local Administrators Group with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.