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

18 lines
659 B
PowerShell
Raw Normal View History

#!/bin/pwsh
2024-03-23 00:27:49 +00:00
param(
[int]$EventID,
[string]$PreparedUsernameProperty,
[string]$PreparedSecretProperty
);
2024-03-23 00:27:49 +00:00
. "$PSScriptRoot/../../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;
2024-03-23 00:27:49 +00:00
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
$context.Remove($AutoLoginTriggerProperty);