clong / DetectionLab

Automate the creation of a lab environment complete with security tooling and logging best practices
MIT License
4.64k stars 987 forks source link

Fix for SetMpPreference failing if Defender is Disabled #715

Closed justintime closed 3 years ago

justintime commented 3 years ago

If you need to rerun provisioning on the Win10 box, and Defender has been disabled in a prior run, the calls to Set-MpPreference and Add-MpPreference will fail with a NativeCommandError and prevent the script from succeeding. This commit adds some idempotency via a check to see if the service is already disabled before running these commands.

clong commented 3 years ago

image