I have a requirement where I want to exclude all the assemblies which are having pattern
Assembly.*.dll
but want to include all the assemblies having pattern
Assembly.Some.*.dll
from the same location through Get-ChildItem
.
I want to achieve this functionality in a single line of script.
You could use the -or
operator inside a Where-Object
filter:
Get-ChildItem -Filter *.dll |Where-Object {
$_.Name -like 'Assembly.Some.*.dll' -or $_.Name -notlike 'Assembly.*.dll'
}
Since any assembly with a name like Assembly.Some.Namespace.dll
will already return true on the first condition, the second condition won't be tested