Detect current step using stages
This commit is contained in:
parent
32fd5aa572
commit
6f011a2600
1 changed files with 3 additions and 1 deletions
|
@ -42,15 +42,17 @@ function New-PersonalUser([Context] $context)
|
||||||
|
|
||||||
Write-Information "Disabling Auto login";
|
Write-Information "Disabling Auto login";
|
||||||
$context.RemoveAutologin();
|
$context.RemoveAutologin();
|
||||||
|
$context.SetStage("DisableUAC");
|
||||||
Restart-Computer;
|
Restart-Computer;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
elseif ((Get-LocalUser $context.AdminName))
|
elseif ($context.GetStage() -eq "DisableUAC")
|
||||||
{
|
{
|
||||||
Enable-PersonalUserAutologon $context;
|
Enable-PersonalUserAutologon $context;
|
||||||
Write-Information "Removing Admin Account";
|
Write-Information "Removing Admin Account";
|
||||||
Get-CimInstance -ClassName "Win32_UserProfile" -Filter "SID = $((Get-LocalUser $context.AdminName).SID)" | Remove-CimInstance;
|
Get-CimInstance -ClassName "Win32_UserProfile" -Filter "SID = $((Get-LocalUser $context.AdminName).SID)" | Remove-CimInstance;
|
||||||
$context.RegisterReboot();
|
$context.RegisterReboot();
|
||||||
|
$context.RemoveStage();
|
||||||
Write-EventLog -LogName Application -Source "Application" -EventId $taskTrigger -Message "This event was created by $env:Username";
|
Write-EventLog -LogName Application -Source "Application" -EventId $taskTrigger -Message "This event was created by $env:Username";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue