VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso
Jump to solution

Filtering specific host based on Datacenter using Get-View?

Hi fellow experts,

How can I get a specific sets of VMhost from a specific Data center when using Get-View?

Get-View -ViewType HostSystem -PipelineVariable esx

Because it does not take any pipeline input: Get-DataCenter | Where {$_.Name -like '*-PROD-*'} | Get-View ....

  • Get-View : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
    At line:1 char:39

Thank you in advance.

/* Please feel free to provide any comments or input you may have. */
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the SearchRoot parameter, point to the MoRef of the Datacenter

$dc = Get-Datacenter -Name MyDC
Get-View -ViewType HostSystem -SearchRoot $dc.ExtensionData.Moref


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the SearchRoot parameter, point to the MoRef of the Datacenter

$dc = Get-Datacenter -Name MyDC
Get-View -ViewType HostSystem -SearchRoot $dc.ExtensionData.Moref


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

AlbertWT
Virtuoso
Virtuoso
Jump to solution

That's great, Thanks LucD.
Where can I find the -Filter parameter for the Get-View?
because sometimes I've seen people are using it as well in the Get-View.
/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Filter parameter is also described in the Get-View online documentation.
But be aware the right-hand operator is a RegEx expression.

You should be able to find examples when you do a Search in here on Get-View and Filter


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos