Skip to content

Commit

Permalink
Added Update-ExploitProtectionSettings.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdgregson committed Jan 10, 2020
1 parent fe5a0e7 commit 3646c29
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Update-ExploitProtectionSettings.ps1
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."
}

0 comments on commit 3646c29

Please sign in to comment.