What do you have in the $vmhost variable ?
Is that a VMHost object or a string with name of the ESXi host ?
If it is a string try to provide a VMHost object.
What do you have in the $vmhost variable ?
Is that a VMHost object or a string with name of the ESXi host ?
If it is a string try to provide a VMHost object.