Add template for Windows Server 2022
This commit is contained in:
24
ws2022/scripts/sysprep.ps1
Normal file
24
ws2022/scripts/sysprep.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
$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"
|
||||
Reference in New Issue
Block a user