I have just started using PowerShell today, and I have an intention list files by a few patterns in an array, for instance:
$matchPattern = (
                  "SomeCompany.SaaS.Core.Mvc*",
                  "SomeCompany.SaaS.Core.UI.Framework*"
                );
I want to list files in a $sourceDir where any of the item in the above array matches.
I can do this, and it works:
foreach ($item in $matchPattern)
{
    Get-ChildItem $sourceDir | Where-Object {$_.Name -like $item}
}
Just for learning purposes, can I do it in pipe-lining?
Something similar to this:
Get-ChildItem $sourceDir | Where-Object { $matchPattern -contains $_.Name  }
                You can just do:
gci "$someDir\*" -include $matchPattern
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With