Cannot disable Windows Defender

I was trying to disable the Windows Defender like this:

commands:
  disable-windows-defender:
    steps:
      - run:
          name: Disable Windows Defender
          shell: powershell.exe
          command: Set-MpPreference -DisableRealtimeMonitoring $true

and it results in this error:

#!powershell.exe
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference : A general error occurred that is not covered by a more specific error code.
At line:1 char:1
+ Set-MpPreference -DisableRealtimeMonitoring $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MSFT_MpPreference:root\Microsoft\...FT_MpPreference) [Set-MpPreference],  
   CimException
    + FullyQualifiedErrorId : HRESULT 0x800106ba,Set-MpPreference
 

Exited with code exit status 1
CircleCI received exit code 1

How may I disable the Windows Defender correctly?

Hi @RaisinTen! Sometimes this happens when Windows Defender is already disabled by default in the machine/executor image. I would start by checking to see if it’s already disabled.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.