Add code for enabling autologin
This commit is contained in:
parent
e235d70bc0
commit
c1979a1197
1 changed files with 18 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
|||
. "$PSScriptRoot/../Scripts/Context.ps1";
|
||||
$preparedUsernameProperty = "AutoLoginUser";
|
||||
$preparedPasswordProperty = "AutoLoginPassword";
|
||||
$autoLoginTriggerProperty = "AutoLoginTrigger";
|
||||
$uacDisablerTriggerProperty = "UACDisablerTrigger";
|
||||
|
||||
function New-PersonalUser([Context] $context)
|
||||
|
@ -75,12 +78,24 @@ function Set-UACState([bool] $value) {
|
|||
function Enable-UACNextLogin([Context] $context) {
|
||||
Set-UACState $true;
|
||||
$tempTask = "PortValhalla Temp";
|
||||
$autoLoginTrigger = Get-Random;
|
||||
$uacDisablerTrigger = Get-Random;
|
||||
|
||||
$key = Get-SystemPolicyKey;
|
||||
$context.Set($autoLoginTriggerProperty, $autoLoginTrigger, "DWord");
|
||||
$context.Set($uacDisablerTriggerProperty, $uacDisablerTrigger, "DWord");
|
||||
|
||||
$optionCollection = [System.Tuple[uint, string, string[]][]]@(
|
||||
[System.Tuple]::Create(
|
||||
$autoLoginTrigger,
|
||||
"PortValhalla AutoLogin Setup",
|
||||
@(
|
||||
". '$PSScriptRoot/../Scripts/Context.ps1';",
|
||||
"`$context = [Context]::new();",
|
||||
"`$username = `$context.Get('$preparedUsernameProperty');",
|
||||
"`$password = `$context.Get('$preparedPasswordProperty');",
|
||||
"`$context.SetAutologin(`$username, `$password);",
|
||||
"`$context.Remove('$preparedPasswordProperty');")),
|
||||
[System.Tuple]::Create(
|
||||
$uacDisablerTrigger,
|
||||
"PortValhalla UAC Disabler",
|
||||
|
@ -128,5 +143,7 @@ function Enable-PersonalUserAutologon([Context] $context)
|
|||
}
|
||||
}
|
||||
|
||||
$context.SetAutologin($context.UserName, $password);
|
||||
$context.Set($preparedUsernameProperty, $context.UserName, "ExpandString");
|
||||
$context.Set($preparedUsernameProperty, $password, "ExpandedString");
|
||||
Write-EventLog -LogName Application -Source "Application" -EventId $context.Get($autoLoginTriggerProperty) -Message "This event was created by $env:Username";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue