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 { $postProcessStage {
Enable-PersonalUserAutologon $context $userName; Enable-PersonalUserAutologon $context $userName;
$context.RegisterReboot();
Set-UserStage $adminRemovalStage; Set-UserStage $adminRemovalStage;
Start-EventDrivenTask $context.Get($uacDisablerTriggerProperty); Start-EventDrivenTask $context.Get($uacDisablerTriggerProperty);
$context.Reboot();
exit; exit;
} }
$adminRemovalStage { $adminRemovalStage {

View file

@ -10,4 +10,8 @@ $context = [Context]::new();
$userName = $context.Get($PreparedUsernameProperty); $userName = $context.Get($PreparedUsernameProperty);
$password = $context.Get($PreparedSecretProperty); $password = $context.Get($PreparedSecretProperty);
$context.SetAutologin($userName, $password); $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"; 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"; . "$PSScriptRoot/../../Scripts/Context.ps1";
$context = [Context]::new(); $context = [Context]::new();
Unregister-ScheduledTask -Confirm:$false $AutoLoginTaskName;
Unregister-ScheduledTask -Confirm:$false $UACDisablerTaskName;
$context.SetUACState($false); $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.Remove($UACDisablerTriggerProperty);
$context.DeregisterNewUserReboot(); $context.DeregisterNewUserReboot();
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
Restart-Computer -Force;