fix(template): re-affirm autologin after reboot before snapshot
This commit is contained in:
@@ -610,6 +610,20 @@ try {
|
||||
-SessionOption $sessionOptions -UseSSL -Port 5986 `
|
||||
-Authentication Basic -ErrorAction Stop
|
||||
|
||||
# Re-affirm autologin — OOBE/first-boot tasks can reset AutoAdminLogon=0 during the reboot.
|
||||
Write-Host "[Prepare] Re-affirming autologin registry settings..."
|
||||
Invoke-Command -Session $session -ScriptBlock {
|
||||
param($user, $pass)
|
||||
$wlKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
|
||||
Set-ItemProperty -Path $wlKey -Name AutoAdminLogon -Value '1' -Type String -Force
|
||||
Set-ItemProperty -Path $wlKey -Name DefaultUserName -Value $user -Type String -Force
|
||||
Set-ItemProperty -Path $wlKey -Name DefaultDomainName -Value '.' -Type String -Force
|
||||
if ($pass -ne '') {
|
||||
Set-ItemProperty -Path $wlKey -Name DefaultPassword -Value $pass -Type String -Force
|
||||
}
|
||||
} -ArgumentList $AdminUsername, $AdminPassword
|
||||
Write-Host "[Prepare] Autologin re-affirmed." -ForegroundColor Green
|
||||
|
||||
# Send graceful shutdown
|
||||
Write-Host "[Prepare] Sending graceful shutdown to VM..."
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user