Move cleanup scripts to proper location

This commit is contained in:
Manuel Thalmann 2024-03-24 18:16:29 +01:00
parent 87a83600db
commit ab17fa75d6
3 changed files with 7 additions and 6 deletions

View file

@ -74,9 +74,9 @@ function New-PersonalUser([Context] $context, [string] $userName)
}
$postProcessStage {
Enable-PersonalUserAutologon $context $userName;
$context.RegisterReboot();
Set-UserStage $adminRemovalStage;
Start-EventDrivenTask $context.Get($uacDisablerTriggerProperty);
$context.Reboot();
exit;
}
$adminRemovalStage {

View file

@ -10,4 +10,8 @@ $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);

View file

@ -9,11 +9,8 @@ param (
. "$PSScriptRoot/../../Scripts/Context.ps1";
$context = [Context]::new();
Unregister-ScheduledTask -Confirm:$false $AutoLoginTaskName;
Unregister-ScheduledTask -Confirm:$false $UACDisablerTaskName;
$context.SetUACState($false);
$context.Remove($AutoLoginTriggerProperty);
Unregister-ScheduledTask -Confirm:$false $UACDisablerTaskName;
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
$context.Remove($UACDisablerTriggerProperty);
$context.DeregisterNewUserReboot();
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
Restart-Computer -Force;