Thank you very much , i will use it and update you ,
i have another quis about add key
i faced problem with add value , althought test finished successfully but there is no key added to VMX file
Script :
$key = @("key1","key2","key3")
$value = @("value1","value2","value3")
$vms=Get-VMHost 10.136.138.1 | get-vm -name qa-l-vrt-138-009| get-view
$i=0
while ($i -le 2) {
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
echo $key[$i]
echo $value[$i]
$extra = New-Object VMware.Vim.optionvalue
$extra.Key=$Key[$i]
$extra.Value=$Value[$i]
$vmConfigSpec.extraconfig += $extra
$vms.ReconfigVM($vmConfigSpec)
$i++
}
and on another ESX (VM) i get this error
Method invocation failed because [System.Object[]] doesn't contain a method named 'ReconfigVM'.
At C:\Users\Administrator\AppData\Local\Temp\f68d3192-a31f-4e1d-8c4d-43d9543da076.ps1:22 char:16
+ $vms.ReconfigVM <<<< ($vmConfigSpec)
+ CategoryInfo : InvalidOperation: (ReconfigVM:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound