Reputation: 1454
Using the script below I am trying to filter out applications that don't have a $requirement like Windows 10. When I run this I am still getting returned results with application requirements containing windows 10.
| Where { $_ -notlike 'All_x64_Windows_10_and_higher_Clients' };
Any idea what I am doing wrong here? Possible issue with the line above?
$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 "
}
}
Upvotes: 0
Views: 157
Reputation: 13537
The -Like Operator is used for WildCard searches in PowerShell. So you need an *
somewhere in your filter.
Try this:
| Where { $_ -notlike "*All_x64_Windows_10_and_higher_Clients*" };
Upvotes: 1