VMware Communities > VMTN > VMware vSphere™ > Automation Tools > vSphere™ PowerCLI > Discussions

This Question is Answered

2 "helpful" answers available (6 pts)
4 Replies Last post: May 24, 2009 10:30 PM by mrajani
Reply

How to remove an extraConfig setting

Apr 18, 2009 6:58 PM

Click to view chavez9119's profile Novice chavez9119 23 posts since
May 25, 2006
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 Re: How to remove an extraConfig setting Apr 19, 2009 3:53 AM
Click to view LucD's profile Champion LucD 2,382 posts since
Oct 31, 2005
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 <Edit Settings><Options><General><Configuration Parameters>. 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.
Reply Re: How to remove an extraConfig setting May 24, 2009 4:49 PM
in response to: LucD
Click to view mrajani's profile Enthusiast mrajani 27 posts since
Dec 6, 2007
VMware

Hi LucD,

This did not work for me. There were no errors, but the variables were not removed.
Reply Re: How to remove an extraConfig setting May 24, 2009 9:56 PM
in response to: mrajani
Click to view LucD's profile Champion LucD 2,382 posts since
Oct 31, 2005
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 ?
Reply Re: How to remove an extraConfig setting May 24, 2009 10:30 PM
in response to: LucD
Click to view mrajani's profile Enthusiast mrajani 27 posts since
Dec 6, 2007
VMware

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.


Actions