brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Start-MpScan runs a Microsoft Defender scan from PowerShell

Security
~/tips/tip-windows-start-mpscan-quickscan

Start-MpScan -ScanType QuickScan

Starts a Defender quick, full or custom scan from the command line instead of the Windows Security app.

The Windows Security app can start a scan, but it takes a few clicks, and you cannot script a click. The Defender module has a cmdlet for it.

Start-MpScan -ScanType QuickScan

The -ScanType parameter accepts QuickScan, FullScan and CustomScan. Without any parameter, Start-MpScan starts a scan on the computer you run it on, as the documentation’s only example shows.

To scan one folder, give it a path:

Start-MpScan -ScanType CustomScan -ScanPath C:\Users\Public\Downloads

The documentation says -ScanPath takes a file name, a folder name or a UNC path. The page does not spell out how -ScanPath combines with the scan types, so check the result on your own machine.

A full scan takes a long time. The -AsJob switch runs the cmdlet as a background job, so you get your prompt back. You then manage it with the *-Job cmdlets, and Receive-Job gets the result:

$job = Start-MpScan -ScanType FullScan -AsJob
Get-Job $job.Id
Receive-Job $job.Id

One caveat: the documentation for this cmdlet does not describe what the scan prints or how it reports threats, so check the Windows Security app afterwards for the outcome. It also does not state whether an elevated prompt is required, so start PowerShell as administrator if the cmdlet complains about access.

None of this was run on a live Windows machine here. It follows the Microsoft documentation.

Further reading: Start-MpScan

More Security tips whoami /groups tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin All Security tips (77) All topics

Link