Win2025-Sysprep
Files for building a reusable Win2025-Sysprep template for vSphere, Terraform, and Ansible Semaphore.
Included
scripts/Prepare-Win2025Sysprep.ps1prepares Windows Server 2025 for templating.files/unattend.xmlis the answer file used bysysprep.
Manual prep before running the script
- Install Windows Server 2025 in a dedicated VM.
- Install VMware Tools.
- Sign in as local
Administrator. - Apply Windows updates and any baseline OS settings you want baked into the template.
- Copy this folder to the VM, for example
C:\Build\Win2025-Sysprep.
What the script does
- enables WinRM for Ansible;
- opens firewall rules for WinRM and RDP;
- enables RDP;
- enables the built-in
Administratoraccount; - switches network profiles to
Privatewhen possible; - cleans temporary files;
- generates
unattend.xml; - runs
sysprep /generalize /oobe /shutdown.
Run
Open PowerShell as Administrator and run:
Set-ExecutionPolicy Bypass -Scope Process -Force
cd C:\Build\Win2025-Sysprep
.\scripts\Prepare-Win2025Sysprep.ps1
If you want OpenSSH installed too:
.\scripts\Prepare-Win2025Sysprep.ps1 -InstallOpenSsh
If you want a different timezone:
.\scripts\Prepare-Win2025Sysprep.ps1 -TimeZone "Russian Standard Time"
After the VM shuts down
- Confirm the VM is powered off in vSphere.
- Convert the VM to a template.
- Name the template
Win2025-Sysprep. - Use that name in Terraform variable
vm_template.
Checklist before converting to template
- VMware Tools are installed and healthy.
- WinRM is responding.
- The VM shut down because of
sysprep. - The VM is not domain joined.
- No machine-specific secrets or unique data remain on the server.
Quick WinRM check
Before running sysprep, you can verify locally:
winrm enumerate winrm/config/listener
Test-WSMan
Notes
- The computer name inside the source VM is not important because Terraform
windows_optionswill rename cloned VMs. - Do not join the template to the domain in advance.
- If you plan to use WinRM over HTTPS, it is usually better to issue the certificate after cloning, not inside the golden image.