dsccommunity / ComputerManagementDsc

DSC resources for for configuration of a Windows computer. These DSC resources allow you to perform computer management tasks, such as renaming the computer, joining a domain and scheduling tasks as well as configuring items such as virtual memory, event logs, time zones and power settings.
https://dsccommunity.org
MIT License
308 stars 83 forks source link

Resource to handle SmartScreen Filter #73

Open johlju opened 7 years ago

johlju commented 7 years ago

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
                }
            }
        }
PlagueHO commented 7 years ago

@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: