【发布时间】:2013-05-01 11:20:24
【问题描述】:
我试图找出一种方法来让这个命令从一组值而不是一个值中过滤。目前我的代码是这样的(当 $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*" })
}
关于为什么第二个代码块不起作用的任何想法或关于我可以做什么的其他想法?
【问题讨论】:
标签: arrays powershell foreach where