Select-Object -First affects prior cmdlet in the pipeline
问题 The PowerShell Strongly Encouraged Development Guidelines that cmdlets should Implement for the Middle of a Pipeline but I suspect that isn't doable for a parameter as -Last for the Select-Object. Simply because you can't determine the last entry upfront. In other words: you will need to wait for the input stream to finish until you define the last entry. To prove this, I wrote a little script: $Data = 1..5 | ForEach-Object {[pscustomobject]@{Index = "$_"}} $Data | ForEach-Object { Write-Host