25 lines
799 B
PowerShell
25 lines
799 B
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$cbUnattend = "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml"
|
|
|
|
if (-not (Test-Path $cbUnattend)) {
|
|
throw "Cloudbase-Init Unattend.xml not found at: $cbUnattend"
|
|
}
|
|
|
|
Write-Host "Removing Packer WinRM firewall rule..."
|
|
Remove-NetFirewallRule -DisplayName "WinRM HTTP" -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "Cleaning temp files..."
|
|
Remove-Item -Path "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "Enabling built-in Administrator account..."
|
|
net user Administrator /active:yes
|
|
net user Administrator /logonpasswordchg:no
|
|
|
|
Write-Host "Running Sysprep /generalize /oobe /shutdown..."
|
|
& "$env:SystemRoot\System32\Sysprep\Sysprep.exe" `
|
|
/generalize `
|
|
/oobe `
|
|
/shutdown `
|
|
/unattend:"$cbUnattend"
|