yashatrevm
Enthusiast
Enthusiast

RuntimeException, FullyQualifiedErrorId : MethodNotFound while executing the script

Hi All,
I am trying to execute the following code

$vmName = Read-Host "Enter the VM Name or regex (VMname*) :"
$vmList = Get-VM $vmName

#Create new Virtual Machince Config Spec
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

#Write new config options to VMs
foreach ($vm in $vmList){

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.tools.toolsUpgradePolicy = "upgradeAtPowerCycle"

$vm.ReconfigVM_Task($vmConfigSpec)
}

======

However, when I execute this code, I hit the following :

=====

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.VM.UniversalVirtualMachineImpl] does not contain a method named 'ReconfigVM_Task'.
At C:\Users\yash.atre\MyScripts\1_test.ps1:14 char:2
+ $vm.ReconfigVM_Task($vmConfigSpec)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

=====

The closest understanding to which I could come is that it might be because I am handling multiple VMs starting with same text, however, that is a requirement. I would greatly appriciate if someone could help me fix this issue.

Thank you

Reply
0 Kudos