In the previous recipe, Selecting columns from the output, we saw how the Select-Object cmdlet can be used to select only the columns we want. In this recipe, we will learn how to limit the output of a cmdlet to a subset of the total items returned.
Limiting the number of output objects
Getting ready
Ensure that you are at a location that has a few files. List out the contents of the current directory and count the number of items returned. If the number is less than 5, you may want to consider adding more items to the directory. Follow these steps to get started:
- Enter the following command to count the number of files and directories at the current path:
PS> (Get-ChildItem -Path .).Count
- If you would like to reduce...