From 1978e12b80ca678af949e01a9c1402356e7668e7 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Tue, 7 Nov 2023 09:59:03 +0100 Subject: [PATCH] Updated WDAC setup to include enable and disable function --- SetupWDAC.ps1 | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/SetupWDAC.ps1 b/SetupWDAC.ps1 index 06aef6b..d74e821 100644 --- a/SetupWDAC.ps1 +++ b/SetupWDAC.ps1 @@ -1,9 +1,36 @@ -$DownloadFile = "https://git.justw.tf/Lightemerald/setup-script/raw/branch/main/{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 "File copied!" \ No newline at end of file +function EnableWDAC { + $DownloadFile = "https://git.justw.tf/Lightemerald/setup-script/raw/branch/main/{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 Show-WDACMenu { + $selection = $null + + do { + Write-Host "What would you like to do?" + Write-Host "1. Enable WDAC" + Write-Host "2. Disable WDAC" + + $selection = Read-Host "Enter the number of your choice" + + switch ($selection) { + "1" { EnableWDAC } + "2" { DisableWDAC } + default { Write-Host "Invalid selection. Please choose 1, 2, or 3." } + } + } while ($selection -ne "1" -and $selection -ne "2" -and $selection -ne "3") +} \ No newline at end of file