Defender Control is a tiny tool which allows you to turn Windows Defender on or off-- and prevents anything else changing that setting.
The program provides two very obvious "Disable..." and "Enable..." buttons where you can make your choice.
There's also a button to launch Defender, and a menu with an option to control Windows Defender's settings.
You can call the program from a script to disable or enable Windows Defender, as required. Use "DefenderControl.exe /d" to disable Defender, "DefenderControl.exe /e" to turn it back on.
We've never had any real difficulty with Windows Defender, but if you've tried to disable it and found it keeps coming back, Defender Control might be able to help.