Enable UAC during Microsoft Account login
This commit is contained in:
parent
1f82f78c7f
commit
412b23cfc2
1 changed files with 16 additions and 0 deletions
|
@ -34,8 +34,24 @@ function New-PersonalUser([Context] $context)
|
|||
|
||||
Write-Host "Registering setup script for all new users";
|
||||
$context.RegisterNewUserReboot();
|
||||
Enable-UACNextLogin;
|
||||
$context.RemoveAutologin();
|
||||
Restart-Computer;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function Enable-UACNextLogin() {
|
||||
$taskName = "PortValhalla"
|
||||
$keyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
|
||||
$propertyName = "EnableLUA";
|
||||
Set-ItemProperty "$keyPath" -Name "$propertyName" -Value 1;
|
||||
|
||||
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument ("-c " + `
|
||||
"Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;" + `
|
||||
"Unregister-ScheduledTask $taskName;");
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogOn;
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
|
||||
$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger;
|
||||
Register-ScheduledTask $taskName $task;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue