10

I'm trying to figure out a way to get this command to filter from an array of values as opposed to one value. Currently this is how my code is (and it works when $ExcludeVerA is one value):

$ExcludeVerA = "7"

$java = Get-WmiObject -Class win32_product | where { $_.Name -like "*Java*"} |
where ({ $_.Version -notlike "$ExcludeVerA*" })

And I'd like $ExcludeVerA to have an array of values like so (this currently doesn't work):

$ExcludeVerA = "7", "3", "4"

foreach ($x in $ExcludeVerA)
{

$java = Get-WmiObject -Class win32_product | where { $_.Name -like "*Java*"} |
where ({ $_.Version -notlike "$ExcludeVerA*" })

}

Any ideas of why this second block of code doesn't work or other ideas of what I can do?

4

2 に答える 2