PortValhalla/scripts/Windows/OS/User/AutoLogin.ps1

18 lines
669 B
PowerShell

#!/bin/pwsh
param(
[int]$EventID,
[string]$PreparedUsernameProperty,
[string]$PreparedSecretProperty
);
. "$PSScriptRoot/../../../Common/Scripts/Context.ps1";
$context = [Context]::new();
$userName = $context.Get($PreparedUsernameProperty);
$password = $context.Get($PreparedSecretProperty);
$context.SetAutologin($userName, $password);
$context.Remove($PreparedUsernameProperty);
$context.Remove($PreparedSecretProperty);
Unregister-ScheduledTask -Confirm:$false $AutoLoginTaskName;
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
$context.Remove($AutoLoginTriggerProperty);