question

MiroKarku-0155 avatar image
0 Votes"
MiroKarku-0155 asked MartinDye-3926 commented

Scanning file(s) by Windows Defender in command line

Hi!

I want to scan files/folders by Windows Defender in command line.
I copied whole help from command line to text file and tried it, but it scans anything other and I don't know what really.
I used command:

"C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -3 -File %path%

Where I'm not sure about scan argument - if is req'd to use the word "scan", and if, don't know if is req'd dash before scan type (normally it is not separate argument).
Also argument -File looks like not working.

Can anybody help me to fix it? And for to be sure add argument to see result to avoid else one mistake?

Thank you in advance.
Miro

not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LeonLaude avatar image
0 Votes"
LeonLaude answered MartinDye-3926 commented

Hi,

You can use the Start-MpScan PowerShell cmdlet to manually scan files with Windows Defender.
Then select what type of scan you want by defining the -ScanType switch.

 Start-MpScan -ScanPath %path% -ScanType {QuickScan | FullScan | CustomScan}


Best regards,
Leon


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, this method works and has an interactive progress bar.
The documentation provided here:

https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/command-line-arguments-microsoft-defender-antivirus?view=o365-worldwide

... for custom scans produces errors and the program path can change if the version is updated (don't want to update the path of the app every time it gets upgraded).

Martin.

0 Votes 0 ·
RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered

Hello,

Welcome to Microsoft Q&A!

Does @LeonLaude 's answer help to solve your issue? If not, you could ask about this issue in Windows 10 General Forum. It's a better place for asking questions like yours about windows 10.


Thank you!


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.