37 lines
1.5 KiB
PowerShell
37 lines
1.5 KiB
PowerShell
function EnableWDAC {
|
|
$DownloadFile = "https://git.justw.tf/Lightemerald/setup-script/raw/branch/main/WDAC/{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip"
|
|
$LocalFile = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Temp\{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip"
|
|
Write-Host "Downloading file from $DownloadFile to $LocalFile"
|
|
Invoke-WebRequest -Uri $DownloadFile -OutFile $LocalFile -UseBasicParsing
|
|
Write-Host "Copying file from $LocalFile to C:\Windows\System32\CodeIntegrity\CiPolicies\Active\"
|
|
Copy-Item -Path $LocalFile -Destination "C:\Windows\System32\CodeIntegrity\CiPolicies\Active\"
|
|
Write-Host "Deleting file from $LocalFile"
|
|
Remove-Item -Path $LocalFile
|
|
Write-Host "WDAC file copied!"
|
|
}
|
|
|
|
function DisableWDAC {
|
|
$LocalFile = Join-Path -Path "C:\Windows\System32\CodeIntegrity\CiPolicies\Active\" -ChildPath "{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip"
|
|
Write-Host "Deleting file from $LocalFile"
|
|
Remove-Item -Path $LocalFile
|
|
Write-Host "WDAC file deleted!"
|
|
}
|
|
|
|
function SetupWDAC {
|
|
param (
|
|
[bool] $enable
|
|
)
|
|
if ($enable) {
|
|
if (Test-Path -Path "C:\Windows\System32\CodeIntegrity\CiPolicies\Active\{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip") {
|
|
Write-Host "WDAC is already enabled!"
|
|
} else {
|
|
EnableWDAC
|
|
}
|
|
} else {
|
|
if (Test-Path -Path "C:\Windows\System32\CodeIntegrity\CiPolicies\Active\{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip") {
|
|
DisableWDAC
|
|
} else {
|
|
Write-Host "WDAC is already disabled!"
|
|
}
|
|
}
|
|
} |