-
Notifications
You must be signed in to change notification settings - Fork 6
/
Update-ExploitProtectionSettings.ps1
35 lines (33 loc) · 1.38 KB
/
Update-ExploitProtectionSettings.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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."
}