vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
753 stars 603 forks source link

Get-HVBaseImageVM - Cannot find an overload for "BaseImageVM_List" and the argument count: "1" #444

Closed JasonP7600 closed 2 years ago

JasonP7600 commented 3 years ago

When trying to run Get-HVBaseImageVM I constantly get : MethodException: C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:7260 Line | 7260 | $BaseImageVMList = $services.BaseImageVM.BaseImageVM_List($Virtua … | ~~~~~~~~~~~~~ | Cannot find an overload for "BaseImageVM_List" and the argument count: "1".

When trying this in PS version 5 I get the same issue. I tried this by looking into the helper.psm1 file: PS C:\Windows\system32> $VirtualCenterId = Get-HVvCenterServer | Select-Object -First 1 -ExpandProperty Id PS C:\Windows\system32> $BaseImageVMList = $services.BaseImageVM.BaseImageVM_List($VirtualCenterId) Cannot find an overload for "BaseImageVM_List" and the argument count: "1". At line:1 char:1

JasonP7600 commented 3 years ago

I think I have found the issue here. I am using Horizon 7.13, which has to have 2 arguments passed. The method actually wants 2 arguments, even though the API says that filterIncompatibleVms is set to false, but there is a note for 7.13 there that not specifying a value it should be set to false so you still need to put that boolean variable in, or set to null. eg: BaseImageVM.BaseImageVm_List($vCenterid,$true) or BaseImageVM.BaseImageVm_List($vCenterid,$null)

In the Helper script only 1 argument is passed and that is the vCenterID and nothing else, hence the reason why the command fails. from the helper script on of the lines that will fail. $BaseImageVMList = $services.BaseImageVM.BaseImageVM_List($VirtualCenterId)

The scripts need to be updated to accommodate for 7.13 users.

mtelvers commented 3 years ago

Isn't this just the same as the issue in #397 ?

JasonP7600 commented 3 years ago

Yip ... it looks like it is ... I did not see that before I posted this initial one

ricoroodenburg commented 2 years ago

I’ve got a fix for you, based on #397. Added some code too.

https://github.com/vmware/PowerCLI-Example-Scripts/pull/489/commits/0234308aeb39bd530896388d8bbb2e530ff81350

Waiting for approval..

kamennikolov commented 2 years ago

Fixed with https://github.com/vmware/PowerCLI-Example-Scripts/pull/428