From c58cc3bbc595829340398b35c377c2dc6abb7576 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 9 Aug 2024 04:29:26 +0200 Subject: [PATCH] Add scripts for controlling UAC --- scripts/Windows/Scripts/Security.ps1 | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/Windows/Scripts/Security.ps1 diff --git a/scripts/Windows/Scripts/Security.ps1 b/scripts/Windows/Scripts/Security.ps1 new file mode 100644 index 00000000..c23c7f0c --- /dev/null +++ b/scripts/Windows/Scripts/Security.ps1 @@ -0,0 +1,36 @@ +$null = New-Module { + $uacOption = "EnableLUA"; + $systemPolicyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"; + + $uacSetter = { + param( + [bool] $Value + ) + + Set-ItemProperty -Path $systemPolicyPath -Name $uacOption -Value ([int]$Value); + } + + <# + .SYNOPSIS + Determines whether UAC is enabled. + #> + function Get-UACStatus { + [bool](Get-ItemProperty -Path $systemPolicyPath -Name $uacOption); + } + + <# + .SYNOPSIS + Enables UAC. + #> + function Enable-UAC { + & $uacSetter $true; + } + + <# + .SYNOPSIS + Disables UAC. + #> + function Disable-UAC { + & $uacSetter $false; + } +}; \ No newline at end of file