VMware Cloud Community
chavez9119
Contributor
Contributor
Jump to solution

How to remove an extraConfig setting

I added the following extraconfig settings

isolation.tools.copy.enable=false

isolation.tools.paste.enable=false

What I should have added was

isolation.tools.copy.disable=true

isolation.tools.paste.disable=true

How can I change or delete these settings?

Here is how I added it originally:

connect-viserver $args[0]

$vmConfigSpec1 = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec1.extraconfig += New-Object VMware.Vim.optionvalue

$vmConfigSpec1.extraconfig[0].Key="isolation.tools.copy.enable"

$vmConfigSpec1.extraconfig[0].Value="false"

$vmConfigSpec2 = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec2.extraconfig += New-Object VMware.Vim.optionvalue

$vmConfigSpec2.extraconfig[0].Key="isolation.tools.paste.enable"

$vmConfigSpec2.extraconfig[0].Value="false"

$VMs = Get-Cluster $args[1] | Get-VM | % {Get-View $_.Id}

foreach ($vm in $VMs) {

$vm.ReconfigVM($vmConfigSpec1)

$vm.ReconfigVM($vmConfigSpec2)

}

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Afaik you can't with the ReconfigVM method of the SDK.

Although the SDK Reference states "An option is removed if the key is present but the value is not set or the value is an empty string." in the VirtualMachineConfigSpec object for the extraConfig property this doesn't seem to work.

This is apparently confirmed by the message you get in the VIC when you go to . There you get a message saying "Entries cannot be removed".

What you can do is to blank out the keys you don't want to apply anymore.

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[0].Key="isolation.tools.copy.enable" 
$vmConfigSpec.extraconfig[0].Value=""

$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[1].Key="isolation.tools.paste.enable" 
$vmConfigSpec.extraconfig[1].Value=""

$VMs = Get-Cluster $args[1] | Get-VM | % {Get-View $_.Id}

foreach ($vm in $VMs) {
  $vm.ReconfigVM($vmConfigSpec)
} 

Note that you don't need to call ReconfigVM for each key, you can all the keys into the extraconfig array and call the method once.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

Afaik you can't with the ReconfigVM method of the SDK.

Although the SDK Reference states "An option is removed if the key is present but the value is not set or the value is an empty string." in the VirtualMachineConfigSpec object for the extraConfig property this doesn't seem to work.

This is apparently confirmed by the message you get in the VIC when you go to . There you get a message saying "Entries cannot be removed".

What you can do is to blank out the keys you don't want to apply anymore.

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[0].Key="isolation.tools.copy.enable" 
$vmConfigSpec.extraconfig[0].Value=""

$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[1].Key="isolation.tools.paste.enable" 
$vmConfigSpec.extraconfig[1].Value=""

$VMs = Get-Cluster $args[1] | Get-VM | % {Get-View $_.Id}

foreach ($vm in $VMs) {
  $vm.ReconfigVM($vmConfigSpec)
} 

Note that you don't need to call ReconfigVM for each key, you can all the keys into the extraconfig array and call the method once.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
mrajani
Enthusiast
Enthusiast
Jump to solution

Hi LucD,

This did not work for me. There were no errors, but the variables were not removed.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

This doesn't remove the variables but blanks them out.

Weren't the variables blanked out ?

Which specific setting did you try to remove/blank out ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
mrajani
Enthusiast
Enthusiast
Jump to solution

Thanks LucD,

It was just setting the values to null. I wanted them removed.

From the subject of this thread it seemed that it would remove the variables.

Reply
0 Kudos
rcardona2k
Immortal
Immortal
Jump to solution

FWIW, there would be two options to use with the OptionValue() objects in extraConfig, either an empty string ("") or a null value. Providing an empty string for the value member is taken literally and the setting in the .vmx file becomes setting = "". I also tried value=null (from C#) and the extraConfig values are completely unaffected and not removed from the .vmx file.

Anyone with further insight is welcome to chime in.

The latest VISDK 4.0 reiterates what's in the v2.5 docs:

extraConfig member documentation

>Additional configuration information for the virtual machine. This describes a set of modifications to the additional options. An option is removed if the key is present but the value is not set or the value is an empty string. Otherwise, the key is set to the new value.

This is clearly not the case.

I may open a VMware SDK SR request on the documentation, since it is not behaving as documented. For this I have to submit sample code and logs from an ESX 4 host.

Reply
0 Kudos
EliSch
Contributor
Contributor
Jump to solution

I run into the same issue. I cannot make the OptionValue to be removed via VI api.

Is there any chance this issue is solved?

Best Regards,

\Eli

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

So it seems like both the api documentation and functionality still will not allow you to remove an entry.  This is pretty frustrating.  I am attempting this in vCO and I am seeing the same behavior.  Hopefully having the empty value won't adversely effect anything.  I am trying to scrub a vCD vm of its cloud identity so the option I am removing is cloud.uuid .

Reply
0 Kudos