Here's how you do it using the Where-Object cmdlet:
$exclude = @(".cs", ".tt", ".xaml", ".csproj", ".sln", ".xml", ".cmd", ".txt") Get-ChildItem -Path $path -Recurse | Where-Object { $exclude -notcontains $_.Extension }
If you do not want directories to be returned in the results, use this:
$exclude = @(".cs", ".tt", ".xaml", ".csproj", ".sln", ".xml", ".cmd", ".txt") Get-ChildItem -Path $path -Recurse | Where-Object { (-not $_.PSIsContainer) -and ($exclude -notcontains $_.Extension) }
Bob m
source share