Why use the CLI installer
Yesterday we covered the design decisions that are hard to change later: FQDN, SSO domain, size, placement and time. The CLI installer turns those decisions into a file. Once the file exists, a deployment is a single command that takes the same path every time.
- Repeatable. The same JSON file deploys the same appliance in the lab, in test and in production, with only the values changed.
- Reviewable. The file can be checked by a colleague before anything is deployed, and its shape can live in source control (without the passwords).
- Unattended. The CLI runs stage 1 (deploying the OVA) and stage 2 (configuring the appliance) back to back, with no wizard to click through.
- Faster recovery. When you need to rebuild a vCenter to restore a file-based backup (Day 27), a ready-made template saves time when it matters most.
- Batch deployment. Several JSON files in one folder can be deployed in one run, and the installer works out the order.
How the CLI installer works
The vCenter Server appliance ISO contains both installers. After you mount it, three folders matter:
vcsa-ui-installer: the graphical installer.vcsa-cli-installer: the CLI installer, with one subfolder per client operating system (win32,lin64andmac) and atemplatesfolder withinstall,upgradeandmigratesubfolders.vcsa: the appliance OVA and the bundled OVF Tool.
When you run vcsa-deploy install, the installer reads your JSON file, validates it, builds an OVF Tool command and deploys the OVA to the target ESXi host or vCenter. It then waits for the appliance to boot and runs stage 2: networking, time, SSO domain creation and service start-up. A typical run takes 30 to 60 minutes, mostly in stage 2.
Run the CLI from a Windows, Linux or macOS machine that can reach the target host and the new appliance address on the network. On Windows versions older than Windows 10, install the Visual C++ redistributable (14.0 or newer) shipped in vcsa\ovftool\win32\vcredist first.
The JSON templates
You never start from an empty file. The ISO ships templates with the minimum parameters for each scenario in vcsa-cli-installer/templates/install:
| Template | Use it when |
|---|---|
embedded_vCSA_on_ESXi.json | Deploying a new, standalone vCenter directly onto an ESXi host. The most common choice for the first vCenter. |
embedded_vCSA_on_VC.json | Deploying onto a host or DRS cluster that an existing vCenter already manages. You target the vCenter, a datacenter and a host, cluster or resource pool. |
embedded_vCSA_replication_on_ESXi.json | Deploying a vCenter that joins an existing SSO domain (Enhanced Linked Mode), onto an ESXi host. |
embedded_vCSA_replication_on_VC.json | The same replication-partner deployment, onto a vCenter-managed host or cluster. |
vCSA_with_cluster_on_ESXi.json | Greenfield builds where vCenter should also create a datacenter and a single-node vSAN cluster managed by vSphere Lifecycle Manager images. |
Copy the template you need to a working folder; never edit the copy on the ISO. Each template has a __version key that matches the installer build, so always start from the template on the ISO you will deploy with rather than from a file you kept from an older release.
The JSON file, section by section
The file has two top-level sections: new_vcsa, which describes the appliance and where it goes, and ceip. Inside new_vcsa there are several subsections:
| Subsection | Key parameters | Notes |
|---|---|---|
esxi | hostname, username, password, deployment_network, datastore | Use only when deploying directly to an ESXi host. The port group must be a standard port group, or a distributed port group with ephemeral binding. |
vc | hostname, username, password, deployment_network, datacenter, datastore, target, optional vm_folder | Use only when deploying through an existing vCenter. Names are case-sensitive and must match the inventory exactly. target ends with a host, cluster or resource pool name. |
appliance | name, deployment_option, thin_disk_mode | name is the VM name. deployment_option combines size and storage, for example small, small-lstorage or medium-xlstorage. |
network | ip_family, mode, system_name, ip, prefix, gateway, dns_servers | system_name is the FQDN and becomes the appliance identity. Use mode static in production. |
os | password, ntp_servers or time_tools_sync, ssh_enable | Root password of the appliance. Choose NTP servers rather than time sync with the host. |
sso | password, domain_name | The SSO administrator password and domain, for example vsphere.local. Replication templates instead name an existing partner to join. |
ovftool_arguments | Any OVF Tool argument | Optional and not validated by the installer. Unknown arguments make the deployment fail. |
The ceip section has a single setting, ceip_enabled. If you set it to true, you must also pass --acknowledge-ceip on the command line.
A few formatting rules catch people out:
- Booleans are lowercase and unquoted:
trueorfalse. - Backslashes and quotes inside strings must be escaped with a backslash, so a Windows path is written with double backslashes.
- ASCII only. The path to the JSON file, the path to the installer, your client user name and every string value must use plain ASCII characters, including passwords.
- Encoding. Save the file as UTF-8.
- Passwords. If you leave a password empty or remove it, the installer asks for it at the console during template verification. That keeps secrets out of the file, but it also means the run is no longer fully unattended.
For the full list of parameters for your exact build, run vcsa-deploy install --template-help, and vcsa-deploy --supported-deployment-sizes for the valid size values.
Command arguments and exit codes
The basic syntax is vcsa-deploy install [arguments] path_to_json. The arguments you will actually use:
| Argument | What it does |
|---|---|
--accept-eula | Accepts the licence agreement. Required for a deployment. |
--acknowledge-ceip | Required only when ceip_enabled is true in the JSON file. |
--precheck-only | Runs template verification and OVF Tool parameter verification. Deploys nothing. Run this every time before a real deployment. |
--verify-template-only | Checks only the template syntax and values. Fast, but does not test connectivity to the target. |
--log-dir=PATH | Writes logs and output to a folder you choose instead of a temporary folder. Always set it, so the logs are easy to find. |
-v, --verbose / -t, --terse | More debug output on the console, or only warnings and errors. |
--no-ssl-certificate-verification | Skips certificate verification for the server connections. Without it, a target with a self-signed certificate makes the installer show the thumbprint and ask you to accept it, which stops an unattended run. Use it only on networks you trust. |
--skip-ovftool-verification | Skips verification of the OVF Tool parameters. Avoid it unless support asks you to use it. |
--pause-on-warnings | Pauses and waits for you to acknowledge each warning. |
--operation-id ID | Tags the run with your own identifier, useful when several deployments run in parallel. |
When the command finishes, check its exit code: 0 means success, 1 a runtime error, 2 a validation error and 3 a template error. Scripts should test the exit code rather than parse console output.
Recommendations
- Run from a jump host on the management network. Stage 2 talks to the new appliance over the network for a long time. A laptop on VPN that sleeps or drops the tunnel breaks the deployment halfway.
- Deploy to an ESXi host, not through a vCenter, for the first vCenter. For later appliances, deploying through the existing vCenter lets you target a cluster and a VM folder.
- Create DNS records first. Forward and reverse records must exist and match before you run the installer. Most failed stage 2 runs are DNS.
- Keep the template, not the passwords. Store the JSON shape and non-secret values in source control. Inject passwords at run time from a vault or a prompt, and delete any file that contains them.
- Leave SSH disabled unless you have a specific need. You can enable it temporarily from the VAMI (Day 3) when support asks.
- Thick-provision production appliances unless you monitor datastore space closely. A full datastore under vCenter is an outage.
- Always run
--precheck-onlyfirst, then the real deployment with exactly the same file. - Back up immediately. After deployment, configure file-based backup before you add hosts.
Security note: the JSON file contains the ESXi root password, the new root password and the SSO administrator password in clear text. Treat it like a credential file: create it at run time, keep it on an encrypted disk and delete it when the deployment ends. The script below does exactly that.
Common mistakes and troubleshooting
- Stage 2 fails or hangs at the start. Usually DNS: the FQDN does not resolve to the IP, the PTR record is missing, or the DNS servers in the file are not reachable from the appliance network. Fix DNS, delete the half-deployed VM and run again. Stage 2 cannot be resumed reliably after a DNS failure.
- Exit code 3 (template error). A JSON syntax problem: a missing comma, a quoted boolean, an unescaped backslash, a non-ASCII character or a template from another release. Run
--verify-template-onlyto find it quickly. - Exit code 2 (validation error). The values are well-formed but wrong: a datastore or port group name that does not exist, a password that fails the policy, a size that does not fit, or a VM name already in use.
- Certificate prompt in an unattended run. The target uses a self-signed certificate. Either trust it first or add
--no-ssl-certificate-verificationon a trusted network. - Distributed port group not accepted. When deploying directly to a host, use a standard port group or an ephemeral distributed port group.
- Time drift. If the ESXi host clock is far off, certificate and SSO steps can fail. Fix host time before deploying.
- Where the logs are. In the folder from
--log-dir, inside aworkflow_<number>subfolder, the filevcsa-cli-installer.logshows each task and the first error. On the appliance itself, stage 2 logs are under/var/log/firstboot.
vCenter 9 and VCF 9
The standalone vCenter 9 ISO still includes the CLI installer, and the deployment command, the folder layout and the precheck workflow are the same as in vCenter 8. Two differences matter:
- Template version. The
__versionvalue and some optional parameters change between releases. Always start from the templates on the ISO you deploy with. Our script reads the version from the ISO for this reason. - VCF deployments. In VMware Cloud Foundation 9, you do not normally run vcsa-deploy yourself. The VCF Installer deploys the management domain vCenter as part of the fleet build and uses the same CLI installer behind the scenes, which is why its logs contain a
vcsa-cli-installer.log. Use the CLI method for standalone vCenter and vSphere Foundation designs, labs and recovery.
Automation script: deploy with pre-checks
This script changes configuration: it deploys a new appliance. It is built to be safe to run repeatedly. It:
- finds
vcsa-deployfor your operating system on the mounted ISO and reads the template version shipped with that build; - checks forward and reverse DNS for the FQDN and that the IP address is not already in use;
- connects to the target ESXi host with VCF PowerCLI and checks host state, datastore space and the port group, and stops if a VM with the same name already exists;
- asks for passwords with
Get-Credential, writes the JSON file, runsvcsa-deploy --precheck-onlyand then the deployment; - deletes the JSON file at the end, whatever happens.
Use -PrecheckOnly to stop after the installer pre-check, or -WhatIf to run every check and see what would be deployed without deploying.
#Requires -Version 7.0
<#
.SYNOPSIS
Day 2 - Generates a vcsa-deploy JSON file from parameters, runs pre-checks and deploys the vCenter appliance.
.DESCRIPTION
Builds an embedded vCenter (on ESXi) deployment file from parameters, checks DNS, the IP address,
the target ESXi host, datastore and port group, then runs vcsa-deploy --precheck-only and,
unless -PrecheckOnly or -WhatIf is used, the full unattended install.
Passwords are collected with Get-Credential. The JSON file holds them in clear text,
so the script deletes it when it finishes.
Part of the Virtual HyperInfra vCenter Configuration Series.
.EXAMPLE
./Deploy-VCSA.ps1 -InstallerRoot E:/ -EsxiHost esx01.corp.local -Datastore ds-mgmt-01 -PortGroup 'VM Network' `
-ApplianceName vcsa01 -Fqdn vcsa01.corp.local -IpAddress 10.10.10.20 -Prefix 24 -Gateway 10.10.10.1 `
-DnsServers 10.10.10.5,10.10.10.6 -NtpServers 10.10.10.5,10.10.10.6 -DeploymentSize small -PrecheckOnly
.EXAMPLE
Same parameters with -WhatIf: runs every check and shows what would be deployed. Nothing is deployed.
.NOTES
Requires PowerShell 7+, the VCF.PowerCLI module and the vCenter installer ISO mounted or extracted.
Test in a lab first. Provided as-is, without warranty.
#>
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)][string]$InstallerRoot,
[Parameter(Mandatory)][string]$EsxiHost,
[Parameter(Mandatory)][string]$Datastore,
[Parameter(Mandatory)][string]$PortGroup,
[Parameter(Mandatory)][string]$ApplianceName,
[Parameter(Mandatory)][string]$Fqdn,
[Parameter(Mandatory)][ipaddress]$IpAddress,
[Parameter(Mandatory)][ValidateRange(8, 30)][int]$Prefix,
[Parameter(Mandatory)][ipaddress]$Gateway,
[Parameter(Mandatory)][string[]]$DnsServers,
[Parameter(Mandatory)][string[]]$NtpServers,
[ValidateSet('tiny', 'tiny-lstorage', 'tiny-xlstorage', 'small', 'small-lstorage', 'small-xlstorage',
'medium', 'medium-lstorage', 'medium-xlstorage', 'large', 'large-lstorage', 'large-xlstorage',
'xlarge', 'xlarge-lstorage', 'xlarge-xlstorage')]
[string]$DeploymentSize = 'small',
[string]$SsoDomain = 'vsphere.local',
[switch]$ThinDisk,
[switch]$EnableSsh,
[switch]$PrecheckOnly,
[switch]$SkipCertificateVerification,
[pscredential]$EsxiCredential,
[pscredential]$RootCredential,
[pscredential]$SsoCredential,
[string]$WorkFolder = (Join-Path -Path (Get-Location) -ChildPath ('vcsa-deploy-' + (Get-Date -Format 'yyyyMMdd-HHmm')))
)
$ErrorActionPreference = 'Stop'
# --- 1. Locate vcsa-deploy for this OS and read the template version shipped with this build ---
$osDir = if ($IsWindows) { 'win32' } elseif ($IsMacOS) { 'mac' } else { 'lin64' }
$exeName = if ($IsWindows) { 'vcsa-deploy.exe' } else { 'vcsa-deploy' }
$vcsaDeploy = Join-Path $InstallerRoot "vcsa-cli-installer/$osDir/$exeName"
$shipped = Join-Path $InstallerRoot 'vcsa-cli-installer/templates/install/embedded_vCSA_on_ESXi.json'
foreach ($p in $vcsaDeploy, $shipped) {
if (-not (Test-Path -Path $p)) { throw "Not found: $p. Is the installer ISO mounted at $InstallerRoot?" }
}
$templateVersion = (Get-Content -Path $shipped -Raw | ConvertFrom-Json).'__version'
Write-Host "Installer found. JSON template version $templateVersion" -ForegroundColor Green
if (-not (Get-Module -ListAvailable -Name 'VCF.PowerCLI', 'VMware.PowerCLI')) {
throw 'Install VCF PowerCLI first: Install-Module -Name VCF.PowerCLI -Scope CurrentUser'
}
# --- 2. Network identity checks: forward DNS, reverse DNS, IP not in use ---
$issues = [System.Collections.Generic.List[string]]::new()
try {
$fwd = [System.Net.Dns]::GetHostAddresses($Fqdn) | ForEach-Object { $_.IPAddressToString }
if ($fwd -notcontains $IpAddress.IPAddressToString) { $issues.Add("Forward DNS for $Fqdn returns '$($fwd -join ', ')', expected $IpAddress") }
} catch { $issues.Add("No forward DNS (A) record for $Fqdn") }
try {
$ptr = [System.Net.Dns]::GetHostEntry($IpAddress).HostName
if ($ptr -ne $Fqdn) { $issues.Add("Reverse DNS for $IpAddress returns '$ptr', expected $Fqdn") }
} catch { $issues.Add("No reverse DNS (PTR) record for $IpAddress") }
if (Test-Connection -TargetName $IpAddress.IPAddressToString -Count 1 -Quiet -TimeoutSeconds 2) {
$issues.Add("$IpAddress already answers ping. Is the address in use?")
}
# --- 3. Target ESXi host checks with VCF PowerCLI (read-only) ---
Set-PowerCLIConfiguration -InvalidCertificateAction Warn -ParticipateInCeip $false `
-Scope Session -Confirm:$false -WhatIf:$false | Out-Null
if (-not $EsxiCredential) { $EsxiCredential = Get-Credential -UserName 'root' -Message "Target ESXi host $EsxiHost" }
$esx = Connect-VIServer -Server $EsxiHost -Credential $EsxiCredential
$jsonPath = $null
try {
$vmhost = Get-VMHost -Server $esx
Write-Host ('Target host {0}: ESXi {1} build {2}, state {3}' -f $vmhost.Name, $vmhost.Version, $vmhost.Build, $vmhost.ConnectionState)
if ($vmhost.ConnectionState -eq 'Maintenance') { $issues.Add('Target host is in maintenance mode') }
if (Get-VM -Server $esx -Name $ApplianceName -ErrorAction SilentlyContinue) {
Write-Host "A VM named '$ApplianceName' already exists on $EsxiHost. Nothing to deploy." -ForegroundColor Yellow
return
}
$ds = Get-Datastore -Server $esx -Name $Datastore -ErrorAction SilentlyContinue
if (-not $ds) { $issues.Add("Datastore '$Datastore' not found on $EsxiHost") }
else {
# Default-storage sizes for vCenter 8.0 U2/U3 (thick). Check the system requirements for your build.
$needGB = @{ tiny = 579; small = 694; medium = 908; large = 1358; xlarge = 2283 }[$DeploymentSize]
$freeGB = [math]::Round($ds.FreeSpaceGB, 0)
Write-Host "Datastore $Datastore has $freeGB GB free"
if ($needGB -and -not $ThinDisk -and $freeGB -lt $needGB) {
$issues.Add("Datastore has $freeGB GB free; '$DeploymentSize' needs about $needGB GB thick-provisioned")
}
}
if (-not (Get-VirtualPortGroup -VMHost $vmhost -Name $PortGroup -ErrorAction SilentlyContinue)) {
$issues.Add("Port group '$PortGroup' not found on $EsxiHost")
}
if ($issues.Count) {
$issues | ForEach-Object { Write-Host " FAIL $_" -ForegroundColor Red }
throw "$($issues.Count) pre-check(s) failed. Fix them and run the script again."
}
Write-Host 'Local pre-checks passed.' -ForegroundColor Green
# --- 4. Collect the new appliance passwords and build the JSON file ---
if (-not $RootCredential) { $RootCredential = Get-Credential -UserName 'root' -Message 'Root password for the new appliance' }
if (-not $SsoCredential) { $SsoCredential = Get-Credential -UserName "administrator@$SsoDomain" -Message 'SSO administrator password' }
$spec = [ordered]@{
'__version' = $templateVersion
'__comments' = @('Generated by Deploy-VCSA.ps1 - Virtual HyperInfra vCenter Configuration Series')
new_vcsa = [ordered]@{
esxi = [ordered]@{
hostname = $EsxiHost
username = $EsxiCredential.UserName
password = $EsxiCredential.GetNetworkCredential().Password
deployment_network = $PortGroup
datastore = $Datastore
}
appliance = [ordered]@{
thin_disk_mode = $ThinDisk.IsPresent
deployment_option = $DeploymentSize
name = $ApplianceName
}
network = [ordered]@{
ip_family = 'ipv4'
mode = 'static'
system_name = $Fqdn
ip = $IpAddress.IPAddressToString
prefix = "$Prefix"
gateway = $Gateway.IPAddressToString
dns_servers = @($DnsServers)
}
os = [ordered]@{
password = $RootCredential.GetNetworkCredential().Password
ntp_servers = @($NtpServers)
ssh_enable = $EnableSsh.IsPresent
}
sso = [ordered]@{
password = $SsoCredential.GetNetworkCredential().Password
domain_name = $SsoDomain
}
}
ceip = [ordered]@{ settings = [ordered]@{ ceip_enabled = $false } }
}
New-Item -ItemType Directory -Path $WorkFolder -Force -WhatIf:$false | Out-Null
$jsonPath = Join-Path $WorkFolder "$ApplianceName.json"
$spec | ConvertTo-Json -Depth 6 | Set-Content -Path $jsonPath -Encoding utf8NoBOM -WhatIf:$false
# --- 5. Installer pre-check: validates the template and OVF Tool parameters, deploys nothing ---
$cliArgs = @('install', '--accept-eula', "--log-dir=$WorkFolder")
if ($SkipCertificateVerification) { $cliArgs += '--no-ssl-certificate-verification' }
Write-Host 'Running vcsa-deploy --precheck-only ...' -ForegroundColor Cyan
& $vcsaDeploy @cliArgs '--precheck-only' $jsonPath
if ($LASTEXITCODE -ne 0) { throw "Installer pre-check failed with exit code $LASTEXITCODE (2 = validation, 3 = template). Logs: $WorkFolder" }
Write-Host 'Installer pre-check passed.' -ForegroundColor Green
if ($PrecheckOnly) { Write-Host 'PrecheckOnly: nothing was deployed.' -ForegroundColor Yellow; return }
# --- 6. Deploy: stage 1 and stage 2 run unattended ---
if ($PSCmdlet.ShouldProcess("$EsxiHost / $Datastore", "Deploy vCenter appliance $ApplianceName ($Fqdn, $DeploymentSize)")) {
Write-Host 'Deploying. This usually takes 30 to 60 minutes ...' -ForegroundColor Cyan
& $vcsaDeploy @cliArgs $jsonPath
if ($LASTEXITCODE -ne 0) { throw "vcsa-deploy failed with exit code $LASTEXITCODE. Logs: $WorkFolder" }
Write-Host "Done. vSphere Client: https://$Fqdn/ui VAMI: https://${Fqdn}:5480" -ForegroundColor Green
}
}
finally {
# The JSON file contains passwords in clear text: always remove it
if ($jsonPath -and (Test-Path -Path $jsonPath)) { Remove-Item -Path $jsonPath -Force -WhatIf:$false }
Disconnect-VIServer -Server $esx -Confirm:$false -WhatIf:$false
}
How to run it
- Mount the vCenter installer ISO (or extract it) on a jump host on the management network, and note the drive or mount path, for example
E:/on Windows or/mnt/vcsaon Linux. Keep every path ASCII-only and preferably without spaces. - Create the forward and reverse DNS records for the new appliance.
- Save the script as
Deploy-VCSA.ps1and run it first with-PrecheckOnly, using the parameters from the example in the help block. Enter the ESXi root account, then the new root and SSO administrator passwords when prompted. - Fix anything reported as
FAILor by the installer pre-check. The log folder is printed on screen. - Run the same command without
-PrecheckOnly. Add-WhatIffirst if you want a last dry run, and-SkipCertificateVerificationif the ESXi host still has its self-signed certificate and you trust the network.
If you run the script again after a successful deployment, it finds the existing VM and stops without changing anything.
Verifying the new appliance
When the script reports success, check three things: that vCenter answers, that the appliance reports healthy, and that time is configured as you specified. This read-only snippet does all three with VCF PowerCLI and the vSphere Automation REST API:
$fqdn = 'vcsa01.corp.local'
$cred = Get-Credential -UserName 'administrator@vsphere.local' -Message "SSO administrator for $fqdn"
# 1. vCenter answers and reports its version
$vc = Connect-VIServer -Server $fqdn -Credential $cred
try {
$vc | Select-Object Name, Version, Build
# 2. Appliance health and time through the REST API (POST /api/session returns the session token)
$token = Invoke-RestMethod -Method Post -Uri "https://$fqdn/api/session" -Authentication Basic -Credential $cred -SkipCertificateCheck
$h = @{ 'vmware-api-session-id' = $token }
[pscustomobject]@{
OverallHealth = Invoke-RestMethod -Uri "https://$fqdn/api/appliance/health/system" -Headers $h -SkipCertificateCheck
Version = (Invoke-RestMethod -Uri "https://$fqdn/api/appliance/system/version" -Headers $h -SkipCertificateCheck).version
NtpServers = (Invoke-RestMethod -Uri "https://$fqdn/api/appliance/ntp" -Headers $h -SkipCertificateCheck) -join ', '
}
Invoke-RestMethod -Method Delete -Uri "https://$fqdn/api/session" -Headers $h -SkipCertificateCheck | Out-Null
}
finally {
Disconnect-VIServer -Server $vc -Confirm:$false
}
You want an overall health of green, the build you expected and your NTP servers listed. -SkipCertificateCheck is there because a new appliance uses VMCA-signed certificates your client does not trust yet; drop it once you have imported the VMCA root certificate (Day 26). Finally, log in to https://<fqdn>/ui and https://<fqdn>:5480 once to confirm both interfaces work, and run the Day 1 baseline script against the new vCenter to capture its empty starting state.
Keep it for later: save the parameter values you used (without passwords) next to your design documents. If you ever need to rebuild this vCenter to restore a backup, the same command recreates the appliance with the same identity in under an hour.
What's next
Day 3: appliance management (VAMI): time, DNS, syslog, access and health, and how to configure them through the vCenter REST API from PowerShell. See the full 30-day series plan.
Want this done for your environment?
We design, deploy and automate vCenter and its alternatives, and can run a full health check of your estate.
Scripts are provided as-is for learning and should be tested in a non-production environment first. VMware, vSphere, vCenter and PowerCLI are trademarks of Broadcom.