Skip to content
Go to file
Cannot retrieve contributors at this time
45 lines (37 sloc) 1.55 KB
Sets all vApp properties for a VM to be user configurable as Terraform v11.5
and the Terraform vSphere provider v1.3 and earlier do not support deploying
VMs with one or more vApp property where the UserConfigurable field is set to
William Lam's nested ESXi VM templates have a 'debug' vApp properties that must
be enabled before Terraform can successfully clone VMs from it. This script
will do so.
param (
Mandatory = $true,
Position = 0,
ValueFromPipeline = $true
[ValidateCount( 1, 100)]
[String[]] $Name
$vms = Get-VM -Name $Name -ErrorAction 'Stop'
foreach ( $vm in $vms ) {
$virtualMachineConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$virtualMachineConfigSpec.changeVersion = $vm.ExtensionData.Config.ChangeVersion
$virtualMachineConfigSpec.vAppConfig = New-Object VMware.Vim.VmConfigSpec
foreach ( $property in $vm.ExtensionData.Config.VAppConfig.Property ) {
$vAppPropertySpec = New-Object -TypeName 'VMware.Vim.VAppPropertySpec'
$vAppPropertySpec.Operation = 'edit'
$vAppPropertySpec.Info = $property
$VAppPropertySpec.Info.UserConfigurable = $true
$virtualMachineConfigSpec.vAppConfig.Property += $VAppPropertySpec
$vm.ExtensionData.ReconfigVM_Task( $virtualMachineConfigSpec )
# Get all the IDs and values
$vm.ExtensionData.Config.VAppConfig.Property |
Select-Object -Property 'ID', 'Value'
You can’t perform that action at this time.