the command get-hcxvm -Name <vmname> not working. As per a workaround there is an alternate command which does the job
get-hcxvm -Container <clustername> -Name <vmname>
However, the challenge is typing the cluster name while executing the command each time(if you have multiple clusters 10+).
So, thought of writing a script, however, running into data type issue.
A VM can reside in any of the cluster. So, instead of typing the CLUSTER name everytime look for a VM we thought of creating an array for 10+ clusters then iterate over it and find the VM information.
$cont1 = "clus1", "clus2"
$vmname = Read-Host -Prompt 'Enter VMname'
try { foreach ($element in $cont1) { Get-HCXVM -Name $vmname -Container $cont1 } -ErrorAction Inquire } Catch { Write-Host "An error occurred:"
Write-Host $_ }
./vmname.ps1
Enter VMname: test_vm
An error occurred:
Cannot bind parameter 'Container'. Cannot convert the "clus1" value of type "System.String" to type "VMware.VimAutomation.Hcx.Types.V1.HCXContainer".
Any help on this really appreciated!