Just seeing if anyone can get me over this hurdle.. tried many things and nearly have it but the wildcard is not matching. i have 2 arrays that will become many. some values have * next to them as i am using the like operator - that all works if looping through a single array btw
individually The first part of the loop will write this out as it should :
value1 value2 value3 Value4
The second part also writes out as it should like this
value1 value2 value3 value4
together they write out like this because of the loop.
value1 value2 value3 value1 value2 value3 value4 value4
The problem is even though the $_ is registering the value when used in the context below $.DisplayName -like $ it never returns a match i have also tried $.DisplayName -like "$" How can i get the wildcard to work in a multi array? It works in a single array but even tho i see the value returns in multi array it does not carry over to the actual command only the write-host?
not sure what i am missing.
$DisplayApps = @("value1", "*Value2*", "*value3*")
$Apps = @("Value4")
$MasterApps = @($DisplayApps,$Apps)
ForEach ($item in $masterapps)
{
Write-host $item
ForEach ($item in $item)
{ Write-Host $item
$AppVer = Get-ChildItem -Path $Path1 | Get-ItemProperty | Where-Object { $_.DisplayName -like $item }
If($AppVer){ Write-Host "YES $item" }
}
}
$_to$itembecause you have given the variable a name. If you were doing aForeach-Objectyou would use$_