Skip to content

Instantly share code, notes, and snippets.

@tmap
Last active November 24, 2024 20:43
Show Gist options
  • Save tmap/e21731e1d0b2baa976e9c35aa7cbe234 to your computer and use it in GitHub Desktop.
Save tmap/e21731e1d0b2baa976e9c35aa7cbe234 to your computer and use it in GitHub Desktop.
$mpCmdRunPath = "C:\Program Files\Windows Defender\MpCmdRun.exe"
$directories = Get-ChildItem -Path C:\ -Directory -recurse -ErrorAction SilentlyContinue
foreach ($directory in $directories) {
$dirPath = $directory.FullName
try {
$output = & $mpCmdRunPath -Scan -ScanType 3 -File "$dirPath\*" 2>$null
if ($output -match "Scanning .* was skipped") {
Write-Output "EXCLUDED: $dirPath"
}
} catch {
continue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment