Reorder UAC disablement steps
This commit is contained in:
parent
0137fd56f3
commit
2dbd1a9fed
1 changed files with 3 additions and 21 deletions
|
@ -45,31 +45,13 @@ function New-PersonalUser([Context] $context)
|
||||||
Restart-Computer;
|
Restart-Computer;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
elseif ((Get-UACState))
|
elseif ((Get-LocalUser $context.AdminName))
|
||||||
{
|
{
|
||||||
Write-EventLog -LogName Application -Source "Application" -EventId $taskTrigger -Message "This event was created by $env:Username";
|
|
||||||
|
|
||||||
for ($i = 0; $i -lt $120; $i++)
|
|
||||||
{
|
|
||||||
if ((Get-UACState))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((Get-UACState))
|
|
||||||
{
|
|
||||||
Write-Error "UAC Could not be disabled!";
|
|
||||||
Read-Host "Press enter to continue anyway";
|
|
||||||
}
|
|
||||||
|
|
||||||
Enable-CurrentUserAutologon $context;
|
Enable-CurrentUserAutologon $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;
|
||||||
|
Write-EventLog -LogName Application -Source "Application" -EventId $taskTrigger -Message "This event was created by $env:Username";
|
||||||
Write-Host "Rebooting";
|
exit;
|
||||||
$context.Reboot();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue