August 17th, 2015

PowerTip: Recurse Specific Number of Levels with PowerShell 5

Doctor Scripto
Scripter

Summary: Learn how to recurse a specific number of levels in a directory with Windows PowerShell 5.0.

Hey, Scripting Guy! Question How can I recurse only three levels into a deeply nested directory structure?

Hey, Scripting Guy! Answer In Windows PowerShell 5.0, the Get-ChildItem cmdlet has a new –Depth parameter
           that will control how deeply to recurse, for example:

Get-childitem c:\fso –recurse –depth 3

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.