LINQ provides object queries when working with .NET objects, SQL, XML, and ADO.Net datasets. It has some performance advantages for in-memory processing, as the following example nicely demonstrates:
$path ="E:\Test" $filter ="TestFile1*" #Get-ChildItem with exclude Measure-Command -Expression { $files = Get-ChildItem -Path "$path\*"-Filter $filter -Exclude *000*| Sort-Object -Property LastWriteTime -Descending | Select-Object -First 5 } | Select-Object -Property TotalSeconds #17 - 20 seconds #Get-ChildItem with Where-Object filtering Measure-Command -Expression { $files = Get-ChildItem -Path $path -Filter $filter | Where-Object Name -NotLike*000*| Sort-Object -Property LastWriteTime -Descending | Select-Object -First 5 } | Select-Object -Property TotalSeconds # 5- 7 seconds #.NET objects combined with LINQ Measure-Command -Expression { $directory = [System.IO.DirectoryInfo]::new($path) $files =$directory.GetFiles($filter) #files contains 50k out of 150k items ...