Powershell - Search Directory with Filtering

sj77
sj77 used Ask the Experts™
on
Hello, Experts,

I need help modifying a quick script.

I am working on a powershell script that will query a directory and store a filtered file w/ extension into a variable.

get-childitem $path -recurse -exclude *.mdb

Open in new window


In the directory, there will be multiple .mdbs, but, the mdb I am looking for and want to get with powershell is 9 characters long  or XXXX.mdb.

Could you help me modify the code so that I can figure this out?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Michael B. SmithManaging Consultant
Commented:
Get-ChildItem $path -Recurse -Include ?????.mdb

Open in new window

Author

Commented:
I entered the code you provided and it helped, but, provided a lot of information. I just want the contents in the Name column. See attached picture.
2018-08-28_09-46-51.png
Try this :
(Get-ChildItem $path -Recurse -Include ?????.mdb).name

Open in new window


Or

(get-childitem $path -Recurse -include ?????.mdb)|select name

Open in new window

Author

Commented:
Thank you both for contributing. that answered my question.
@SJ77,

I am glad that I was able to assist with this. However, I just used @Michael B. Smith 's answer and added to it.. Please when you get a moment, modify the question to show that he was an assist on this so he gets points as well..


Thanks

ITGUY565

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial