ComputerManagementDsc icon indicating copy to clipboard operation
ComputerManagementDsc copied to clipboard

Resource to handle SmartScreen Filter

Open johlju opened this issue 7 years ago • 1 comments

I used this script to turn off Smart Screen filter. I suggest we make this into a resource, or add this as a parameter to an existing resource. I do not know if this module is the correct one for this. If not, let me know and I will submit this in the correct module.

SmartScreen Filter: FAQ

If there is a better way to accomplish this, then please let me know. 😄

        Script (New-ResourceName -Name 'EnableSmartScreenFilter')
        {
            SetScript = {
                <#
                    'Off' equals off.
                    'Prompt' equals 'Warn before running an unrecognized app, but don't require administrator approval'.
                    'RequireAdmin' equals 'Get administrator approval before running an unrecognizd app from the Internet (recommended)'
                #>
                Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name SmartScreenEnabled -ErrorAction Stop -Value 'RequireAdmin' -Force
            }

            TestScript = {
                $smartFilterStatus = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name SmartScreenEnabled -ErrorAction SilentlyContinue).SmartScreenEnabled

                return ($smartFilterStatus -eq 'RequireAdmin')
            }

            GetScript = {
                $smartFilterStatus = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name SmartScreenEnabled -ErrorAction SilentlyContinue).SmartScreenEnabled
                
                return @{
                    SmartFilterStatus = $smartFilterStatus
                }
            }
        }

johlju avatar Jun 07 '17 12:06 johlju

@johlju - sounds like a good idea - and a really easy one to do if someone is looking for something easy to start with. Especially as you've provided much of the code :grin:

PlagueHO avatar Jul 11 '17 23:07 PlagueHO