Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to achieve the same output in Powershell as I would get by running dir [pattern] /s /b in cmd.exe.

Recursive directory search, with a filter, printing out just the full file paths of found files.

share|improve this question
up vote 3 down vote accepted

dir -Filter *.txt -Recurse | Select Fullname

(Dir being a PowerShell alias for Get-ChildItem).

Fullname includes the Path (like /B), if you just want the file names, use Select Name.

share|improve this answer
Get-ChildItem . -recurse | Select-Object Name

the . means "this folder" a .. would mean the parent folder of this folder. This is an example of the output that I get:

Name
----
0409
1033
AdvancedInstallers
appmgmt
ar-SA
BestPractices
bg-BG
Boot
catroot
catroot2
CodeIntegrity
com
config
cs
cs-CZ
da-DK
de

to include a pattern use -filter or -include. Personally I use -include because it seems more intuitive to me. It also allows multiple patterns:

Get-ChildItem . -recurse -include *.exe, *.dll | Select-Object Name
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .