Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Where-Object filtering using an array

$
0
0

Greetings! Trying to use Where-Object to filter out the returned data from Get-ChildItem. I essentially want to include everything that matches "Microsoft Lync Server". This works fine for matching "Microsoft Lync Server", but I can't seem to figure out the syntax to exclude those that match anything in the array.

$filter = @("Debugging Tools","Resource Kit Tools","Best Practices Analyzer","Meeting Room Portal")
(Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where-Object {$_.DisplayName -imatch "Microsoft Lync Server"}) | Select-Object DisplayVersion,displayname | Sort-Object DisplayVersion -Descending 

I've tried using something like

(Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where-Object {$_.DisplayName -imatch "Microsoft Lync Server" -and $_.DisplayName -notin $filter}) | Select-Object DisplayVersion,displayname | Sort-Object DisplayVersion -Descending 

As well as -notcontains -notmatch, etc. to no avail. Ideas?



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>