Friday, 26 July 2013

Searching all local drives for files using Windows Powershell

There's often a "forensic" side to software development. Unfortunately source control and continuous integration aren't going to be in place on all projects that you work on and, from time to time, you'll need to track down some elusive source code. I remember once helping to track down the source code for an important project on an old hard drive in the company owner's garage!

At the moment, I'm helping to pin down local copies of source code on some developers' PCs and needed a quick way of searching for all Visual Studio solutions on their hard drives. The following Powershell script searches recursively through all folders on all local drives for files with the ".sln" extension and outputs to a file.

Look at the script on github if you can't see the code in-line above.

The main challenge was getting the list of available drives. "Get-PSDrive -PSProvider FileSystem" will get you all local drives, but includes CD / DVD drives which might not be available. Filtering this list further using "Where-Object -Property Free" will restrict the list to available drives.


  1. This comment has been removed by the author.

  2. This "Where-Object -Property Free" doesnt seem to exist. When I tested this I got this error: "Where-Object : A parameter cannot be found that matches parameter name 'Property'."

    Was this custom built?

  3. Aw, this has been an extremely good post. In notion I have to set up writing in this way moreover ? taking time and actual effort to make a top notch article? but exactly what can I say? I procrastinate alot and also by no indicates seem to go done.

  4. An impressive share, I recently given this onto a colleague who was simply performing a little analysis for this. And then he actually bought me breakfast because I ran across it for him.. smile. So well then, i?ll reword that: Thnx for any treat! But yeah Thnkx for spending some time to discuss this, Personally i think strongly concerning this and enjoy reading much more about this topic. If you can, as you grow expertise, could you mind updating your blog site with a lot more details? It is actually extremely of great help for me. Large thumb up in this blog post! Who Makes the Most Reliable Hard Drives? - NayaShopi