Skip to content

Instantly share code, notes, and snippets.

@jakerobinson
Created November 25, 2019 19:28
Show Gist options
  • Save jakerobinson/9cb529ae40393a1b5c7cdcb7cda0c073 to your computer and use it in GitHub Desktop.
Save jakerobinson/9cb529ae40393a1b5c7cdcb7cda0c073 to your computer and use it in GitHub Desktop.
$vm = Get-VM twodiskvm
$disk = Get-HardDisk -VM $vm -Name "Hard disk 3"
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = 'edit'
$spec.deviceChange[0].Device = $disk.ExtensionData
$spec.DeviceChange[0].Device.UnitNumber = 0
$vm.ExtensionData.ReconfigVM($spec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment