HI,
I'm trying to filter out the local datastores but I'm not getting the desired results.
Code:
Get-Datastore | Select @{N="LUN";E={$_.Name}},
@{N="Total VMs";E={@($_ | Get-VM).Count}} |
Where-Object {$_Name -Notlike "Datastore1*"}
Thanks
As a general rule, you want to filter first where possible for increased efficiency down the pipeline. That's no exception here:
Try:
Get-Datastore | Where-Object {$_Name -Notlike "Datastore1*"} |
Select @{N="LUN";E={$_.Name}}, @{N="Total VMs";E={@($_ | Get-VM).Count}}
As a general rule, you want to filter first where possible for increased efficiency down the pipeline. That's no exception here:
Try:
Get-Datastore | Where-Object {$_Name -Notlike "Datastore1*"} |
Select @{N="LUN";E={$_.Name}}, @{N="Total VMs";E={@($_ | Get-VM).Count}}
This worked thanks!
Get-Datastore | Where-Object {$_.Name -Notlike "Datastore*"} |
Select @{N="LUN";E={$_.Name}},
@{N="Total VMs";E={@($_ | Get-VM).Count}}
and thanks for the tip!