'PowerShell filtering twice on the same property

I would like to filter the content of a variable by two criteria referring to the same property. I ran into some struggle finding the correct syntax.

It looks like this:

$g = $allsites | Where-Object {($_.Name -like "[g]*") -and ($_.Name -notlike "[GRP-]*)"}

What I'm trying to achieve: Create the variable $g with the filtered content of the variable $allsites where the Site Name starts with with the letter "G" no matter the following letters. This result has to be filtered again. The content of the variable $g should contain site which are not named starting the expression "GRP-" only.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source