Can someone help me determine why functions from the PowerCLI reference book fail on this line?
$perfMgr = Get-View (Get-View ServiceInstance).content.perfManager
The error is:
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not null or empty and then try the comma
nd again.
At line:1 char:20
+ $perfMgr = Get-View <<<< (Get-View ServiceInstance).content.perfManager
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Are you connected to a vSphere server (ESXi or vCenter) ?
Check by displaying the content of
$global:defaultVIServers
If that doesn't return anything, you will have to use the Connect-VIServer cmdlet to connect to an ESXi server or a vCenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your reply. Yes, I am connected to a vCenter session when this happens. I can run other cmdlets fine.
Ok, does
Get-View ServiceInstance
return anything ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference