Question:
I am trying to run the Get-VM and filter out some VM’s by name.
So for example Get-VM | -name isnotlike “Web1” and “Web2”
How would I do this?
or something like this? But this doesn’t work
1 2 |
Get-VM -Name -notlike WEBIMAGE1,WEBIMAGE2 |
Answer:
Pipe your output from Get-VM
to Where-Object
:
1 2 |
Get-VM | Where-Object { $_.Name -notlike '*Web1*' -and $_.Name -notlike '*Web2*'} |