PowerCLI: Scripted edit of a VMX file

From VI-Toolkit
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Scripted edit of a VMX file

author: Craig Baltzer

Description

Craig shows here how you can adjust keys and values in a scripted manner for the hardware configuration of your virtual machine.

Code

 $vm = Get-View (Get-VM +NameofVMtoUpdate+).ID
 $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
 $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
 $vmConfigSpec.extraconfig[0].Key="lefthandsideofentry"
 $vmConfigSpec.extraconfig[0].Value="rigthhandsideofentry"
 $vm.ReconfigVM($vmConfigSpec)

Where

  • NameofVMtoUpdate is the name of the VM you want to update (from the vCenter inventory)
  • lefthandsideofentry is the advanced configuration entry you want to set
  • rigthhandsideofentry is the value for the advanced configuration entry

Location

VMTN: Scripted edit of a VMX file