Need help getting the Where-Object filter in the right place

Hello

I'm trying to filter local data warehouses, but I do not get the expected results.

Code:

Get-Datastore. Select @{N = "MON"; E={$_. Name}},

@{N = "Total virtual machines"; E={@($_ | Get - VM). County}} |

Where-Object {$_Name-Notlike "Datastore1 *"}

Thank you

As a general rule, you want to first filter when it is possible for greater efficiency in the pipeline.  Which is no exception here:

Try:

Get-Datastore. Where-Object {$_Name-Notlike "Datastore1 *"} |

Select @{N = "MON"; E={$_. Name}}, @{N = "Total virtual machines"; E={@($_ | Get - VM). County}}

Tags: VMware

Similar Questions

Maybe you are looking for