我正试图找出一种方法,使此命令可以从值数组中过滤,而不是从单个值中进行过滤。当前我的代码是这样的(当$ExcludeVerA是一个值时它可以工作):
$ExcludeVerA = "7"
$java = Get-WmiObject -Class win32_product | where { $_.Name -like "*Java*"} |
where ({ $_.Version -notlike "$ExcludeVerA*" })
我希望$ExcludeVerA具有以下数值的数组(目前无法实现):
$ExcludeVerA = "7", "3", "4"
foreach ($x in $ExcludeVerA)
{
$java = Get-WmiObject -Class win32_product | where { $_.Name -like "*Java*"} |
where ({ $_.Version -notlike "$ExcludeVerA*" })
}
有关于为什么这段第二段代码不起作用的想法,或者其他我可以做些什么的建议吗?