Created
October 21, 2017 11:26
-
-
Save naamancampbell/1aa3338c316b4543115e68e5fc633f8f to your computer and use it in GitHub Desktop.
Disables UAC without privilege escalation. NB. Must run from another host (mgmt).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## | |
## 1. Save file on mgmt host. | |
## - change 'COMPUTERNAME' to target hostname | |
########## | |
Configuration Disable-UAC { | |
Import-DscResource -ModuleName PsDesiredStateConfiguration | |
Import-DscResource -ModuleName xSystemSecurity -Name xUac | |
Node 'COMPUTERNAME' { | |
xUAC NeverNotifyAndDisableAll { | |
Setting = "NeverNotifyAndDisableAll" | |
} | |
} | |
} | |
Disable-UAC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## | |
## 2. Run the following commands on remote host. | |
## - change 'COMPUTERNAME' to target hostname | |
## - Use `$AdminCred = Get-Credential` as an alternative to .\CloudFormation-PowerShell-Creds.ps1 | |
## | |
## *** WARNING *** - this script will reboot the target host without prompting | |
## | |
########## | |
$TargetHost = "COMPUTERNAME" | |
Set-PSRepository -InstallationPolicy Trusted -Name "PSGallery" | |
Install-Module xSystemSecurity -Scope CurrentUser | |
$AdminCred = .\CloudFormation-PowerShell-Creds.ps1 -AccessCredential Admin -CredentialPath C:\Admin\Keys\CF-Creds-20171018T0954207027 | |
$CIMSession = New-CimSession -ComputerName $TargetHost -Credential $AdminCred | |
Start-DscConfiguration -Path "C:\Users\Admin\Desktop\Disable-UAC" -CimSession $CIMSession -Wait -Verbose | |
Restart-Computer $TargetHost -Credential $AdminCred -Protocol WSMan -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$UAC = Get-ItemProperty -Path "registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system" -Name EnableLUA | |
$UAC.EnableLUA | |
Start-Process -FilePath powershell.exe -verb RunAs -WorkingDirectory C: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment