I am trying to filter/match the operating system from Get-ADComputer and only return computers that have Windows 7 and above:
$computer = Get-ADComputer -properties OperatingSystem | Where-Object {operatingsystem -match "*Windows 7*|*Windows 8*|*Windows 10*"} |
Where-Object {$_.name -like "*-*"} |
Where-Object {$_.name -NotLike "V7-*"} |
Where-Object {$_.name -NotLike "*-NONE"} |
Where-Object {$_.name -NotLike "*-ONCALL"} |
Where-Object {$_.name -NotLike "*-BLACKBAUD"} |
Where-Object {$_.name -NotLike "SC-WIN7-1"} |
Where-Object {$_.name -NotLike "UT-SWCLIENT-01"} |
Select-Object -Expand Name
but when I do that, the debugger asks for a -Filter parameter
I have also tried:
$computer = Get-ADComputer -properties OperatingSystem -filter {(operatingsystem -match "*Windows 7*|*Windows 8*|*Windows 10*")} |
but I get an error:
Get-ADComputer : Error parsing query: '(operatingsystem -match "*Windows 7*|*Windows 8*|*Windows 10*")' Error Message: 'Operator Not supported:
-match' at position: '18'.
So what's the correct/best way to do this?