PowerShell: Display Get-ChildItem -Recurse Results in One Table


Often you may want to use the command Get-ChildItem -Recurse in PowerShell to recursively retrieve all filenames from a directory and display the results in one output table.

You can use the following syntax to do so:

Get-ChildItem -Recurse *.txt | Select FullName

This particular example will return the full path of each .txt file in the current directory and all subfolders.

The following example shows how to use this syntax in practice.

Example: Display Get-ChildItem -Recurse Results in One Output Table

Suppose we use the following syntax with the Get-ChildItem cmdlet to recursively return all .txt files from the current directory:

Get-ChildItem -Recurse *.txt

The following screenshot shows how to use this syntax in practice:

Notice that this returns information about each .txt file in the current directory, separated by the individual subfolder names.

We can use the following syntax to instead return these results in a single output table:

Get-ChildItem -Recurse *.txt | Select FullName

The following screenshot shows how to use this syntax in practice:

PowerShell display ChildItem -Recurse results in one table

Notice that this returns only the full path of each .txt file in the current directory and all subfolders, grouped together in a single output table.

Note that you can also use return as many properties as you’d like by using the Select statement:

Get-ChildItem -Recurse *.txt | Select LastWriteTime, Length, FullName

The following screenshot shows how to use this syntax in practice:

Feel free to include whatever properties you’d like in the Select statement.

Related Tutorials

The following tutorials explain how to perform other common tasks in PowerShell:

PowerShell: How to Use Get-ChildItem with Filter
PowerShell: How to Use Get-ChildItem with Multiple Filters
PowerShell: How to Use Get-ChildItem to Get Full Path of Files
PowerShell: How to Use Get-ChildItem to Return Files Only

Leave a Reply