ClearDefenderHistory.cmd clears the Windows Defender “Protection history” by creating a scheduled task, configured to run as SYSTEM, that clears the Windows Defender logs on next restart of the computer.
Note: Previous versions of this script were able to clear the history without a restart. A change to Windows Defender security in the Spring of 2024 broke the previous method. Until a better method is found, a restart is now required.
Some people may want to run this script just to clean things up and not see old detections under Protection history. For others, it fixes an issue where Defender continues to throw a false positive even after new definitions have been installed that should eliminate the detection.
Note: Some antivirus software may falsely detect the download as a virus. This can happen any time you download a new script and may require extra steps to whitelist the file.
See the comments in the script for additional options.