Summary: Use the new -depth parameter to control how far down a directory you can search.
I have a large file structure to search but I only want to go two folders deep on the search. Is there a way to do this in PowerShell?
Certainly! In PowerShell 5.0, you can use the -depth parameter to specify how many branches deep you’d like to limit from the search root. Here, we can search the C:\Users\CurlyBlue folder for DOCX files but only go to two levels below. Here is an example:
Get-Childitem C:\Users\CurlyBlue -include *.docx -depth 2