-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Update-ExploitProtectionSettings.ps1
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
$guid = New-Guid | ||
$dest_dir = "$env:programfiles" | ||
$file_url = "https://raw.githubusercontent.com/jdgregson/Windows-10-Exploit-Protection-Settings/master/ExploitProtectionSettings.xml" | ||
$file_path = "$dest_dir\ExploitProtectionSettings-$guid.xml" | ||
|
||
try { | ||
"test" > "$dest_dir\test.$guid" | ||
Remove-Item "$dest_dir\test.$guid" | ||
} catch { | ||
Write-Warning "Could not write to `"$dest_dir`". Are you running this as an administrator?" | ||
Write-Host "No changes were made." | ||
Exit | ||
} | ||
|
||
Write-Host "Downloading new settings XML..." -NoNewline | ||
Invoke-WebRequest -Uri $file_url -OutFile $file_path | ||
if (Test-Path $file_path) { | ||
Write-Host "DONE" -ForegroundColor "DarkGreen" | ||
Write-Host "Verifying new settings XML..." -NoNewline | ||
if ((Set-ProcessMitigation -PolicyFilePath $file_path -IsValid) -eq "Is Valid XML: True") { | ||
Write-Host "DONE" -ForegroundColor "DarkGreen" | ||
Write-Host "Applying new settings XML..." -NoNewline | ||
Set-ProcessMitigation -PolicyFilePath $file_path | ||
Write-Host "DONE" -ForegroundColor "DarkGreen" | ||
Remove-Item $file_path | ||
} else { | ||
Write-Host "FAIL" -ForegroundColor "DarkRed" | ||
Write-Warning "$file_path is not valid." | ||
Write-Host "No changes were made." | ||
} | ||
} else { | ||
Write-Host "FAIL" -ForegroundColor "DarkRed" | ||
Write-Warning "The XML file was not found after download." | ||
Write-Host "No changes were made." | ||
} |