How to use the -recursive parameter in Get-ChildItem using PowerShell?


To display the contents of the subfolders including files and folders, -Recurse parameter is used.

Command

Get-ChildItem -Path D:\Temp -Recurse

-Recurse parameter will not display the hidden files and folders.

Output

Directory: D:\Temp
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       13-12-2019     09:52                GPO_backup
d-----       24-11-2018     11:31                LGPO
-a----       07-05-2018     23:00            301 cars.xml
-a----       29-12-2017     15:16           4526 healthcheck.html
-a----       29-12-2017     15:16           4526 healthcheck1.html
-a----       08-12-2017     10:24          48362 servicereport.html
-a----       08-12-2017     10:24          48362 servicereport1.html
-a----       08-12-2017     10:16            393 style.css
-a----       08-12-2017     11:29           7974 Test.xlsx
-a----       25-10-2017     08:13            104 testcsv.csv
-a----       12-12-2017     23:04           1034 testhtmoutput.html
    Directory: D:\Temp\GPO_backup
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       24-11-2018     11:34                {C9C3DB4C-2E51-4201-B3C3-7C0F1ACECBE9}
    Directory: D:\Temp\GPO_backup\{C9C3DB4C-2E51-4201-B3C3-7C0F1ACECBE9}
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       24-11-2018     11:34                DomainSysvol
-a----       24-11-2018     11:34           6215 Backup.xml
-a----       24-11-2018     11:34            602 Bkupinfo.xml

Updated on: 23-Jan-2020

836 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements