I am change my VM devices to disable hotplug. The code I am using are
if ($strUseCase -eq 'Horizon'){
My-Logger "Disable the Ability to Add and Remove Virtual Hardware While the VM Is Running"
$oVMName = VMware.VimAutomation.Core\Get-VM -Name $strVMName
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$extra = New-Object VMware.Vim.OptionValue
$extra.Key = 'Devices.Hotplug'
$extra.Value = $false
$spec.ExtraConfig += $extra
$oVMName.ExtensionData.ReconfigVM($spec)
}
I am getting the following error
[11-23-2020_03:47:29] Disable the Ability to Add and Remove Virtual Hardware While the VM Is Running
Exception calling "ReconfigVM" with "1" argument(s): "A specified parameter was not correct:
config.extraConfig["Devices.Hotplug"]"
At line:10 char:5
+ $oVMName.ExtensionData.ReconfigVM($spec)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
I double-check the spelling and can't seem to find the error. What am I missing?
FYI, got it to work, all I did was changing the syntax from
$extra.Value = $false
to
$extra.Value = false
It looks like that VM is powered on.
You can't change that setting while the VM is powered on.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hum, let me double-check, pretty sure it was off.
It could also be the casing you used.
Afaik, that parameter is all lower-case, like devices.hotplug
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just double check, VM is power off and switch key to all lowercase, still the same error. Any suggestion?
Did you follow the procedure outlined in KB1012225?
Especially the steps for the parent VM.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
FYI, got it to work, all I did was changing the syntax from
$extra.Value = $false
to
$extra.Value = false