VMware Cloud Community
VMware Employee
VMware Employee

vcsa error when using powershell to encapsulate the CLI deployment

Greetings all! 

I'm updating an older powershell script I used to deploy VC. In essence, it mounts the VCSA ISO, extracts the embedded_vCSA_on_ESXi.json file, creates a $config variable ($config = (get-content -raw $VCSA_JSON_ORIG) | convertfrom-json),

updates the $config using current environment specific variables, 

then writes it back to json ($VCSA_JSON = $config | convertto-json | set-content –path "$VCSA_JSON")

and finally executes the script (Invoke-Expression “$($DriveLetter):\vcsa-cli-installer\win32\vcsa-deploy.exe install --no-ssl-certificate-verification --accept-eula $VCSA_JSON -v”

It throws a (somewhat, IMHO) cryptic error about previous version of the install command and running without a subcommand ...

But ... when I simply grab the embedded_vCSA_on_ESXi.json from the ISO, and manually edit the file, and pass that json to the script, it works as expected (for --precheck-only, --verify-template, as well as the full script execution).

I looked through this group for similar errors and found Solved: vcsa-deploy.exe JSON syntax validator broken on vC... - VMware Technology Network VMTN

My issue, might be slightly different ... I think it is simply when the converts back to json format using convertto-json cmdlet, there is a syntax issue .. and it may be something related to the square brackets, as that is the only difference, I can see between the two json files (the one created using the convertfrom-json and convertto-json cmdlets, which does not work) and the extracted json which does work.

Soooo ... my question then becomes how can i use the convertto-json cmdlet to properly process and pass the square brackets used in the json file? Or ... is there another clever way to pass this info back (w/proper syntax) so I can in the same powershell script extract the json from the iso (to future-proof future version changes of this file), pass in the environment-specific values, and write to json and execute the cli deployment? What follows within the powershell script is the VC configuration.

I've included the two different json files and some of the VCDeployScript ...

Thanks in advance!


0 Kudos
0 Replies