I just started using PowerShell today, and I have intent files with several templates in an array, for example:
$matchPattern = (
"SomeCompany.SaaS.Core.Mvc*",
"SomeCompany.SaaS.Core.UI.Framework*"
);
I want to list files in $sourceDirwhere matches any element from the specified array.
I can do this and it works:
foreach ($item in $matchPattern)
{
Get-ChildItem $sourceDir | Where-Object {$_.Name -like $item}
}
Just for training, can I do this in pipe lining?
Something like this:
Get-ChildItem $sourceDir | Where-Object { $matchPattern -contains $_.Name }
source
share