This PowerShell script shows how to enable SmartScreen in Windows 8.
Some of users want to use script to enable SmartScreen in Windows 8 due to some automation tasks. This script can help user to enable SmartScreen via script on multiple computers.
Step1: Start the PowerShell Console with administrator. To run the script in the Windows PowerShell Console, type the one command< Script Path> at the Windows PowerShell Console.
For example, type C:\Script\ EnableSmartScreen.ps1
The step is shown in the following figure.

The “OptionType” parameter has two parameters and their respective functions are described as follows:
The default value of “OptionType” parameter is 2.
1 – Warn before running an unrecognized app, but don’t require administrator approval
2 – Get administrator approval before running an unrecognized app from the Internet (recommended)
Example 1: Type the C:\Script\EnableSmartScreen.ps1
command in the Windows PowerShell Console. It will enable SmartScreen as “Get administrator approval before running an unrecognized app from the Internet (recommended)”

Example 2: Type the C:\Script\EnableSmartScreen.ps1 -OptionType 1 command in the Windows PowerShell Console.
The command shows how to set SmartScreen setting option.

Example 3: Type the $cre = Get-Credential "Server20120830\Administrator" to get a credential object based on a user name and password and type the command C:\Script\EnableSmartScreen.ps1 -OptionType 1 -ComputerName "Server20120830" -Credential $cre in the Windows PowerShell Console.
The above commands will set SmartScreen setting option on remote computer.

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
If($Credential)
{
Write-Verbose "Setting the registry key of SmartScreen on computer[$CN]."
Invoke-Command -ComputerName $CN -Credential $Credential `
-ScriptBlock {
$KeyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"
New-ItemProperty -Path $KeyPath -Name EnableSmartScreen -Value $using:OptionType -PropertyType DWord -Force | Out-Null
Write-Host "Turn on SmartScreen successfully."
}
}
Else
{
Write-Verbose "Setting the registry key of SmartScreen on computer[$CN]."
Invoke-Command -ComputerName $CN `
-ScriptBlock {
Param($OptionType)
$KeyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"
New-ItemProperty -Path $KeyPath -Name EnableSmartScreen -Value $using:OptionType -PropertyType DWord -Force | Out-Null
Write-Host "Turn on SmartScreen successfully."
}
}
If($Credential) { Write-Verbose"Setting the registry key of SmartScreen on computer[$CN]." Invoke-Command -ComputerName $CN-Credential $Credential ` -ScriptBlock { $KeyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"New-ItemProperty-Path $KeyPath-Name EnableSmartScreen -Value $using:OptionType -PropertyType DWord -Force |Out-Null Write-Host "Turn on SmartScreen successfully." } } Else { Write-Verbose"Setting the registry key of SmartScreen on computer[$CN]." Invoke-Command -ComputerName $CN ` -ScriptBlock { Param($OptionType) $KeyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"New-ItemProperty-Path $KeyPath-Name EnableSmartScreen -Value $using:OptionType -PropertyType DWord -Force |Out-Null Write-Host "Turn on SmartScreen successfully." } }
Windows PowerShell 3.0
Windows 8