Just Getting Specific Files in PoSh–#SQLNewBlogger


Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

Just a quick one today, but a tip I hope I remember. While working on a script, I wanted to just get backup files in PoSh. I tried this:

Get-ChildItem -Path $BackupPath -File -Include *.bak

That got me this:

2019-09-23 10_06_19-cmd - powershell


Why not? Apparently, you need the –Recurse parameter, even though there are no subdirectories in this folder. A bug, IMHO, but who knows. In any case, adding the parameter makes things work. Thanks, SO.

2019-09-23 10_11_59-cmd - powershell


This was a quick 5 minute thing. After researching and testing for 10 minutes, and finding the solution, I wrote this up.

You could do that with anything you get working.

Original post (opens in new tab)
View comments in original post (opens in new tab)


5 (2)




5 (2)