In this article
If you want your Windows cloud templates in VCF Automation to run a cloudConfig on first boot, set passwords or create users, the Windows template needs Cloudbase-Init. In this post the whole template build is automated: a VCF Automation cloud template deploys a builder VM with a static IP, and one Orchestrator workflow installs and configures Cloudbase-Init inside it through VMware Tools, cleans it up and clones it to a template.
Tested on: VCF Automation 9.1.1 (VM Apps organization), VCF Operations Orchestrator 9.1.1 (embedded), Windows Server 2022 Standard, Cloudbase-Init 1.1.8 (stable x64 MSI).
How Cloudbase-Init fits into VCF Automation
Cloudbase-Init is the Windows counterpart of cloud-init. When VCF Automation deploys a vSphere machine that has a cloudConfig, it hands that content to the VM as OVF environment data. Cloudbase-Init runs as a Windows service at boot, reads that data through its OvfService metadata service, and runs the plugins you configured: create a user, set a password, run a #ps1_sysnative script and so on. Without Cloudbase-Init in the template, the cloudConfig is simply ignored on Windows.
One design choice up front: I do not sysprep the template myself. My cloud templates assign static IPs, and for that VCF Automation applies a vSphere customization spec (here one called windows), which runs sysprep, sets the hostname and applies the IP on every deployment. So the template stays a plain, non-generalized Windows VM with Cloudbase-Init installed and its service set to Automatic. Cloudbase-Init keys its plugin state per instance, so it runs again on every new VM.
What you need
- The cloud template LAB – Windows – Cloudbase-Init Builder (YAML below). It deploys the builder VM from a plain Windows Server 2022 template.
- The workflow CloudBlogger – Windows – Build Cloudbase-Init Template. It does everything else in one run.
- My workflow Guest OS Script Engine (on GitHub). It copies a resource element into the guest through VMware Tools, replaces
[PLACEHOLDER]variables and returns the output. - The prep script, saved as the resource element
LAB/Scripts/lab-cloudbaseinit-template-prep.ps1. - The configuration element
LAB/Windows/LAB_WindowsGuestwithguestUsernameandguestPassword(SecureString): the local administrator of the plain Windows template.
Everything except the cloud template comes in one Orchestrator package (see Download from GitHub). The package doesn’t carry the password, so set guestPassword after you import it.
Step 1: Deploy the builder VM
Nothing special here: the plain windows2022_template through imageRef, the windows customization spec, and a static IP from the VCF Automation IP range on my tagged lab network. Save it as a cloud template and deploy it with the defaults:
formatVersion: 1
inputs:
vmName:
type: string
title: Builder VM name
default: wincbi
cpuCount:
type: integer
title: vCPUs
default: 4
memoryMb:
type: integer
title: Memory (MB)
default: 8192
resources:
builder-vm:
type: Cloud.vSphere.Machine
properties:
name: ${input.vmName}
imageRef: windows2022_template
cpuCount: ${input.cpuCount}
totalMemoryMB: ${input.memoryMb}
customizationSpec: windows
networks:
- network: ${resource.mgmt-net.id}
assignment: static
mgmt-net:
type: Cloud.vSphere.Network
properties:
networkType: existing
constraints:
- tag: net:lab-vm-mgmt

About five minutes later the VM was up as wincbi050 (my naming setup adds the number) at 10.20.44.211, with VMware Tools running.
Step 2: Run the build workflow
Run CloudBlogger – Windows – Build Cloudbase-Init Template with these inputs:
vm: the builder VM from Step 1. It must be powered on with VMware Tools running.templateName: the template to create, defaultwindows2022_cbinit_template. The workflow stops if a VM or template with that name already exists.templateFolder: optional VM folder for the template. Empty means the builder VM’s folder.refreshImages: run a private image enumeration on the VCF Automation vSphere cloud accounts at the end, so the new template shows up forimageRefstraight away. Default on.

The workflow then does four things, with no input from you:
- Validate: checks that the VM is powered on, has VMware Tools running and is not already a template, checks that the template name is free, and reads the guest credentials and the prep script.
- Prepare the guest: runs the prep script five times through Guest OS Script Engine, one mode at a time:
check,cbinit,guestprep,status,finalize. It stops on the first mode that doesn’t printLAB_RESULT=0. - Shut down and clone: shuts the guest down and clones the powered-off VM to a template. It clones instead of converting because the builder VM belongs to a VCF Automation deployment.
- Refresh images: starts the image enumeration on the vSphere cloud accounts in VCF Automation, so the new template shows up without a manual sync.
The prep script is one PowerShell file with a branch per mode. Guest OS Script Engine replaces [LAB_MODE] before it copies the script into the VM:
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$mode = '[LAB_MODE]'
$result = 1
try {
switch ($mode) {
'check' { <# OS, IP, DNS, can we reach cloudbase.it, free space on C: #> }
'cbinit' { <# download + silent install + write both .conf files #> }
'guestprep' { <# RDP on, firewall Public off, IE ESC off, execution policy #> }
'status' { <# service state and metadata_services line #> }
'finalize' { <# stop service, clear logs and plugin state, remove the MSI #> }
}
} catch {
Log ('ERROR ' + $_.Exception.Message)
}
Write-Output ('LAB_RESULT=' + $result)
How one script runs five steps: [LAB_MODE] is only a placeholder. Task 2 loops over the workflow attribute prepModes (check, cbinit, guestprep, status, finalize) and calls Guest OS Script Engine once per mode, passing the mode as LAB_MODE in scriptVariables. Guest OS Script Engine swaps the placeholder before it copies the script into the VM, so $mode = '[LAB_MODE]' arrives as $mode = 'cbinit' and only that branch runs:
for (var m = 0; m < prepModes.length; m++) { var sv = new Properties(); sv.put("LAB_MODE", prepModes[m]); // e.g. "cbinit" p.put("resourceElement", prepScript); // lab-cloudbaseinit-template-prep.ps1 p.put("scriptVariables", sv); var t = wf.execute(p); // Guest OS Script Engine // ...wait for it, then stop unless the output has LAB_RESULT=0}
One file means one resource element to maintain, and the build log still shows which step failed. To re-run a single step, set prepModes to just that mode.
Every line the script prints starts with LAB_, and the last line is always LAB_RESULT=0 or LAB_RESULT=1, so the workflow only has to look for that line to know whether a step worked. The cbinit mode downloads the stable x64 MSI from cloudbase.it and installs it silently with Administrator as the user and the service running as LocalSystem, the same choices VMware’s documentation asks for in the setup wizard.
I ran it from VCF Automation as a user with rights on the vSphere cloud account, and it took two and a half minutes. My real windows2022_cbinit_template already existed, so I set templateName to windows2022_cbinit_blogtest for this run; everything else stayed at the defaults. This is the buildLog output, exactly as the workflow returned it:
Builder: wincbi059 (vm-2234), template: windows2022_cbinit_blogtest
--- check ---
LAB_OS=Microsoft Windows Server 2022 Standard Evaluation 10.0.20348
LAB_HOST=WINCBI059
LAB_IP=Ethernet0 10.20.44.222/24
LAB_DNS=10.20.44.11,10.20.44.12
LAB_NET_OK=https://cloudbase.it/downloads/CloudbaseInitSetup_Stable_x64.msi 200
LAB_C_FREE_GB=68.5
LAB_RESULT=0
--- cbinit ---
2026-11-29T05:03:08 Downloading https://cloudbase.it/downloads/CloudbaseInitSetup_Stable_x64.msi
2026-11-29T05:03:13 Installing Cloudbase-Init silently
2026-11-29T05:03:48 msiexec exit code 0
2026-11-29T05:03:49 Wrote cloudbase-init.conf and cloudbase-init-unattend.conf (OvfService only)
LAB_CBI_SERVICE=Stopped Auto LocalSystem
LAB_CBI_VERSION=Cloudbase-Init 1.1.8 1.1.8.0
LAB_RESULT=0
--- guestprep ---
2026-11-29T05:04:00 RDP enabled
2026-11-29T05:04:01 Firewall Public profile off
2026-11-29T05:04:01 Defender real-time protection off (may be reverted by Tamper Protection)
2026-11-29T05:04:01 IE Enhanced Security Configuration off
2026-11-29T05:04:01 Execution policy Unrestricted (LocalMachine)
LAB_RESULT=0
--- status ---
LAB_CBI_SERVICE=Stopped Auto LocalSystem
LAB_CBI_METADATA=metadata_services=cloudbaseinit.metadata.services.ovfservice.OvfService
LAB_C_FREE_GB=68.1
LAB_RESULT=0
--- finalize ---
2026-11-29T05:04:19 Finalized: Cloudbase-Init stopped (Automatic), logs and plugin state cleared
LAB_RESULT=0
--- clone ---
template windows2022_cbinit_blogtest vm-2235 uuid=4231866c-f296-e19b-37d2-60bd2bcca1d3 instanceUuid=50319abd-3d8e-07a5-5ccf-23d7992a101f
--- images ---
enumeration started: vCenter=202
The timestamps are 12 hours behind because of the time zone in my customization spec (see Things I ran into). The images line shows the enumeration started; a few minutes later a cloud template with imageRef: windows2022_cbinit_blogtest deployed without any manual image sync. If the user running the workflow has no rights on the vSphere cloud account, that step reports a 403 instead and the run still completes; click Sync images on the cloud account once in that case.

What the cbinit mode writes
Cloudbase-Init reads two files in C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf. cloudbase-init.conf is used by the service on normal boots; cloudbase-init-unattend.conf is only used during the sysprep specialize pass. The important line in both is metadata_services: list only OvfService, so Cloudbase-Init doesn’t spend time probing for OpenStack, EC2 or Azure metadata that vCenter never offers. This is the cloudbase-init.conf the script writes:
[DEFAULT]
username=Administrator
groups=Administrators
inject_user_password=true
first_logon_behaviour=no
config_drive_raw_hhd=true
config_drive_cdrom=true
config_drive_vfat=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.ovfservice.OvfService
plugins=cloudbaseinit.plugins.windows.createuser.CreateUserPlugin,cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin,cloudbaseinit.plugins.common.sshpublickeys.SetUserSSHPublicKeysPlugin,cloudbaseinit.plugins.common.userdata.UserDataPlugin,cloudbaseinit.plugins.common.localscripts.LocalScriptsPlugin
allow_reboot=true
stop_service_on_exit=false
pluginslists only plugins that work withOvfService, in the order they run.UserDataPluginis the one that runs yourcloudConfigscript.- I left
NetworkConfigPluginout on purpose. The customization spec applies the static IP; letting Cloudbase-Init touch the NIC too only creates a race. first_logon_behaviour=nomeans users aren’t forced to change the password at first login. VMware’s doc usesalways; pick what suits you.- The log lands in the
logfolder next toconf. It is the first place to look when acloudConfigdoesn’t run.
cloudbase-init-unattend.conf gets the same settings, with its own log file, only the MTU plugin, and no reboots:
[DEFAULT]
username=Administrator
groups=Administrators
inject_user_password=true
config_drive_raw_hhd=true
config_drive_cdrom=true
config_drive_vfat=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init-unattend.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.ovfservice.OvfService
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin
allow_reboot=false
stop_service_on_exit=false
The finalize mode then leaves the service on Automatic but stopped, and clears the log and plugin state, so every VM cloned from the template starts clean.
Using the template in a cloud template
imageRefwith the template name. I prefer that to an image mapping, because the cloud template then runs in another environment after a copy-paste.customizationSpec: windowsandassignment: staticon the network, so the spec does sysprep, hostname and IP.- A
cloudConfigwhose first line is#ps1_sysnative. Cloudbase-Init’s UserDataPlugin runs it as a 64-bit PowerShell script.


#ps1_sysnative script that Cloudbase-Init runs on first boot.⚠️ The big gotcha: Cloudbase-Init starts while the customization spec is still finishing. In my first test the cloudConfig ran on the temporary WIN-... hostname, a long installer in it failed, and the next customization reboot killed the script halfway. Cloudbase-Init had already marked the plugin as done, so it never ran again. The customization also reset the Administrator password afterwards. The fix: keep the cloudConfig short. Let it write the real work into a script and register it as a SYSTEM scheduled task (at startup, plus started right away). The task waits until the image state is IMAGE_STATE_COMPLETE and the hostname is the final one, does the work once, then removes itself.

Things I ran into
- Time zone: my
windowscustomization spec still has the time zone set to UTC-12, so every timestamp written inside the guest, including the build log above, is 12 hours behind. Set the right time zone in your own spec. - Clone, not convert: the builder VM is part of a VCF Automation deployment, and converting it to a template would leave that deployment pointing at a VM that no longer exists. The workflow clones it, so delete the builder deployment yourself once the template works.
- Image refresh needs rights: the refresh step runs as whoever runs the workflow. Started with an account that has no rights on the vSphere cloud account, it returned a 403. Running it from VCF Automation as a user with those rights fixed it; otherwise click Sync images on the cloud account.
- Defender comes back:
guestprepturns off Defender real-time protection, but Tamper Protection can switch it on again. The log line says so; it doesn’t affect Cloudbase-Init. - Released IPs are not free straight away: after I deleted test deployments, their addresses stayed in the RELEASED state in the VCF Automation IP range for more than 30 minutes, and my small range ran out. Size the range with some headroom.
Download from GitHub
- 📦 cloudbase-init-template-vcfa on GitHub: the Orchestrator package
in.co.cloudblogger.cbinit(the build workflow, Guest OS Script Engine, the prep script and theLAB_WindowsGuestconfiguration element without the password), the builder cloud template YAML, the prep script and the four workflow scripts, with setup steps in the README. - 🔍 Peek inside this package in vRO Peekage to read every workflow, script and element without importing it.
Wrapping up
Cloudbase-Init itself is simple: one MSI, two config files, OvfService as the only metadata service. Putting those steps in one script and one Orchestrator workflow turns the template build into a single run that never needs an RDP session: deploy the builder, run the workflow, and the template is ready for any Windows cloud template with a cloudConfig. If you build Windows templates a different way, I’d like to hear how in the comments.
Discover more from Cloud Blogger
Subscribe to get the latest posts sent to your email.
Enjoyed this post?
Was this helpful?





























Leave a Reply