使用下面的脚本我试图过滤掉没有像Windows 10那样的$需求的应用程序。当我运行这个时,我仍然得到包含Windows 10的应用程序需求的返回结果。Where子句没有正确过滤
| Where { $_ -notlike 'All_x64_Windows_10_and_higher_Clients' };
任何想法我在做什么错在这里?上面这行可能存在问题?
$warningpreference = "SilentlyContinue"
Get-Content C:\temp\Applications.txt | foreach-object {
$app = Get-CMApplication -Name "$_";
[XML]$appXML =$app.SDMPackageXML;
$Requirement = $appXML.AppMgmtDigest.DeploymentType.Requirements.Rule.OperatingSystemExpression.Operands.RuleExpression.RuleID | Where { $_ -notlike 'All_x64_Windows_10_and_higher_Clients' };
If ($Requirement -ne $null -or $Requirement.length -gt 0) {
Write-output "Application Name: $_ | Requirement: $Requirement "
}
}
好了,怎么办属性值的样子,你想过滤掉?你在那里的条件和使用'-ne'...''一样,所以我想你想用'-notlike'出于某种原因,但是无法得到正确的模式。 – Joey
我想只返回他们没有Windows10需求的应用程序。好像任何过滤我做的是不工作 – user1342164