diff --git a/scripts/Windows/OS/User.ps1 b/scripts/Windows/OS/User.ps1 index f563519b..d57682b0 100644 --- a/scripts/Windows/OS/User.ps1 +++ b/scripts/Windows/OS/User.ps1 @@ -50,6 +50,7 @@ function New-PersonalUser([Context] $context) Enable-CurrentUserAutologon $context; Write-Information "Removing Admin Account"; Get-CimInstance -ClassName "Win32_UserProfile" -Filter "SID = $((Get-LocalUser $context.AdminName).SID)" | Remove-CimInstance; + $context.RegisterReboot(); Write-EventLog -LogName Application -Source "Application" -EventId $taskTrigger -Message "This event was created by $env:Username"; exit; } @@ -84,8 +85,7 @@ function Enable-UACNextLogin([Context] $context) { "Unregister-ScheduledTask -Confirm:`$false '$uacDisablerName';", ". '$PSScriptRoot/../Scripts/Context.ps1';", "`$context = [Context]::new();", - "`$context.EntryPoint = '$($context.EntryPoint)';", - "`$context.RegisterReboot((Get-Item 'Registry::HKEY_USERS\$((Get-LocalUser $context.UserName).SID)'));", + "`$context.DeregisterNewUserReboot();", "Restart-Computer -Force;"))); schtasks /Create /SC ONEVENT /EC Application /MO "*[System[Provider[@Name='Application'] and EventID=$taskTrigger]]" /TR cmd.exe /TN "$tempTask";