Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Key = "LocalSettingOverrideDisableRealtimeMonitoring"
  2. $PolicyRegKey = (Get-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection").$Key
  3.  
  4. If ($PolicyRegKey -eq 1) {
  5.     $CheckResult = "Enabled"
  6. } ElseIf ($PolicyRegKey -eq 0) {
  7.     $CheckResult = "Disabled"
  8. } Else {
  9.     $CheckResult = "Not Configured"
  10. }
  11.  
  12. $ButtonType = [System.Windows.MessageBoxButton]::YesNoCancel
  13. $MessageboxTitle = “Real-Time Protection policy switch
  14. $Messageboxbody = “Current policy setting is: $CheckResult `n `n Press 'YES' to Enable policy `n Press 'NO' to Disable policy `n Press 'CANCEL' to exit”
  15. $MessageIcon = [System.Windows.MessageBoxImage]::Warning
  16. $MessageReturn = [System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$messageicon)
  17.  
  18.  
  19.  
  20. If ($MessageReturn -eq "Yes") {
  21.     $PolValue = 1
  22. } ElseIf ($MessageReturn -eq "No") {
  23.     $PolValue = 0
  24. } ElseIf ($MessageReturn -eq "Cancel") {
  25.     Break    
  26. }
  27.  
  28. If ($CheckResult -eq "Not Configured") {
  29.     New-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name $Key -PropertyType dword -Value $PolValue
  30. }
  31.  
  32. Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name $Key -Value $PolValue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement