In the following code, I am trying to enable the Windows Defender using powershell
Sub Enable_Disable_Windows_Defender_Using_PowerShell()
Dim wshShell As Object
Dim wshShellExec As Object
Dim strCommand As String
Rem Enable = false - Disable = true
strCommand = "Powershell -nologo -WindowStyle Hidden -ExecutionPolicy Bypass -Command ""Set-MpPreference -DisableRealtimeMonitoring $false"""
Set wshShell = CreateObject("WScript.Shell")
Set wshShellExec = wshShell.Exec(strCommand)
End Sub
There is no error at executing the code but I didn't get the Windows Defender Eabled Any idea ..?
I tried this but doesn't work for me too
Sub Enable_Disable_Windows_Defender_Using_PowerShell()
Dim wshShell As Object
Dim wshShellExec As Object
Dim strCommand As String
Rem Enable = false - Disable = true
strCommand = "Powershell -nologo -Command ""Start-Process powershell -Verb runAs"""
Set wshShell = CreateObject("WScript.Shell")
Set wshShellExec = wshShell.Exec(strCommand)
strCommand = "Powershell -nologo -WindowStyle Hidden -ExecutionPolicy Bypass -Command ""Set-MpPreference -DisableRealtimeMonitoring $false"""
Set wshShell = CreateObject("WScript.Shell")
Set wshShellExec = wshShell.Exec(strCommand)
End Sub