#requires -Version 5.1 <# admin_uac_silent.ps1 — sets ConsentPromptBehaviorAdmin = 0 so future elevations from this admin user happen silently. Reversible via the same key (default value = 5). #> $ErrorActionPreference = 'Continue' $log = 'C:\Users\acbot\leakhunt\artifacts\soak\admin_uac.log' Start-Transcript -Path $log -Force | Out-Null try { if (-not ([Security.Principal.WindowsPrincipal]::new( [Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Host 'ERROR: not elevated.' -ForegroundColor Red exit 1 } $k = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System' $before = (Get-ItemProperty -Path $k -Name ConsentPromptBehaviorAdmin -ErrorAction SilentlyContinue).ConsentPromptBehaviorAdmin Write-Host ("ConsentPromptBehaviorAdmin BEFORE = {0}" -f $before) Set-ItemProperty -Path $k -Name ConsentPromptBehaviorAdmin -Value 0 -Type DWord -Force $after = (Get-ItemProperty -Path $k -Name ConsentPromptBehaviorAdmin).ConsentPromptBehaviorAdmin Write-Host ("ConsentPromptBehaviorAdmin AFTER = {0}" -f $after) -ForegroundColor Green } catch { Write-Host "FATAL: $($_ | Out-String)" -ForegroundColor Red } Stop-Transcript | Out-Null Read-Host 'press enter to close'