April 5th, 2015

PowerTip: Use PowerShell to Find Folders that Match Pattern

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to find folders with names that match a specific pattern.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find the path to folders that have names that match a specific pattern?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet and the –Filter parameter with a pattern that matches the name, and then
           specify the  –Directory parameter. Here is an example that matches folders that have a four-letter name:

Get-ChildItem E:\Data\ScriptingGuys -filter "????" -Directory |

 % { $_.fullname }

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.