Skip to content

Instantly share code, notes, and snippets.

@wise-io
Last active June 8, 2022 17:28
Show Gist options
  • Save wise-io/4fa3fc00274a45ffa6b9df1f92126abc to your computer and use it in GitHub Desktop.
Save wise-io/4fa3fc00274a45ffa6b9df1f92126abc to your computer and use it in GitHub Desktop.
Runs a Windows Defender Scan
# Runs a Windows Defender Scan
param(
[ValidateSet('Full', 'Quick', 'Offline', IgnoreCase)]
[string]$Type = 'Quick', # Scan type (defaults to quick scan)
[System.IO.FileInfo]$Path # Optional local path to scan
)
# Format type parameter
$Type = (Get-Culture).TextInfo.ToTitleCase($Type)
# Update definitions
Update-MpSignature
# Run scan
if ($Path) {
Start-MpScan -ScanType 'Custom' -ScanPath $Path
}
elseif ($Type -eq 'Offline') {
Start-MpWDOScan
exit
}
else {
Start-MpScan -ScanType $Type
}
# Remove active threats
Remove-MpThreat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment