Add scripts for controlling UAC
This commit is contained in:
parent
dee942b881
commit
25d4810147
1 changed files with 36 additions and 0 deletions
36
scripts/Windows/Scripts/Security.ps1
Normal file
36
scripts/Windows/Scripts/Security.ps1
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue