3 ms·
Take your pick: # most common in script, vs at shell Get-ChildItem | Where-Object { $_.Length -gt 4kb } gci | where length -gt 4kb # longest m
by jodrellblank 7y ago
Take your pick:
# most common in script, vs at shell
Get-ChildItem | Where-Object { $_.Length -gt 4kb }
gci | where length -gt 4kb
# longest most restrictive with namespaces,
# most stable over time,
# least risk of hitting the wrong command
# or wrong property as surroundings change
Microsoft.PowerShell.Management\Get-ChildItem | Microsoft.PowerShell.Core\Where-Object -Property Length -gt 4kb
# shortest(?)
gci|? le* -gt 4kb
# because you can
switch(gci){{$_.length-gt4kb}{$_}}
gci | & { process{ if($_.Length -gt 4kb) { $_ } } }
$larges, $smalls = (gci).where({$_.length -gt 4kb}, 'split')
[linq.enumerable]::where([string[]][io.directory]::EnumerateFiles($pwd), [func[string,bool]]{param($f) [io.fileinfo]::new($f).Length -in 0..4kb})
In Powershell you can tab complete "Length" in the filter, from the available properties of the objects coming out of gci, which is neat.