-1

I'm trying to use get-childitem to search all directories with name like "temp","temp2","temp3"....

How can I assume to use wildcard to search directories names? Thanks all.

  • 1
    Have you looked at what [`Get-Help Get-ChildItem`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.1) says? – Jeff Zeitlin Feb 25 '21 at 12:43

1 Answers1

0

I tried gci -filter _comp* -Recurse and it works, returning all matching folders and files, of course you can omit the -Recurse switch to just get the matching folders and files in the current folder.

If you want to return all files (regardless of matching name) contained in those matching folders then you'll need to pipe to output to ForEach-Object and do some magic there.

endurium
  • 849
  • 1
  • 8
  • 16