Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Last active September 26, 2024 17:33
Show Gist options
  • Save kwilczynski/7336212e73986ae9a2600cf634159f4d to your computer and use it in GitHub Desktop.
Save kwilczynski/7336212e73986ae9a2600cf634159f4d to your computer and use it in GitHub Desktop.
Using govc to add ExtraConfig setting to a virtual machine in VSphere.
export GOVC_URL=''
export GOVC_USERNAME=''
export GOVC_PASSWORD=''
# Disabled. Only use if TLS is completely broken.
# export GOVC_INSECURE=1
export GOVC_TLS_CA_CERTS=$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE' 2>/dev/null)
while read vm; do
govc vm.power -s -vm.dns=${vm} && govc vm.power -off -vm.dns=${vm}
govc vm.change -e 'mem.hotadd=true' -e 'vcpu.hotadd=true' -vm.dns=${vm}
govc vm.change -c 2-vm.dns=${vm}
govc vm.power -on -vm.dns=${vm}
govc vm.info -vm.dns=${dns} -json | jq -r '.VirtualMachines[].Config.ExtraConfig[] | select(.Key | contains("hotadd"))'
read -p "Next? " -n 1 -r answer && [[ $answer =~ ^[Yy]$ ]] || break && echo
done < list.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment