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.

20 comments:

  1. Nếu bạn nơi để mua do dien may cu thì hãy ghé qua địa chỉ sau http://thangghom.com/. Chúng tôi là nơi cung cấp các thiết bị điện máy cũ với giá cả và chất lượng hàng đầu. Khi bạn thắc mắc mua tủ lạnh ở đâu rẻ nhất tphcm hay nơi nào bán máy lạnh cũ giá rẻ? Thì bạn không cần phải tìm nơi đó nữa, hãy ghé qua thằng ghờm shop nơi bạn có thể mua máy giặt cũ tphcm, tủ lạnh, máy lạnh cũ tại tphcm với giá cả tốt nhất và chất lượng hàng đầu.

    Có thể bạn chưa biết hệ thống định vị toàn cầu gps là gì? Hãy ghé qua ngôi nhà kiến thức để tìm hiểu nhé. Đây là nơi tổng hợp các kiến thức hữu ích.

    ReplyDelete
  2. thanks. i was just searching about finding the local file in best way. its really superb. and its more powerful. keep sharing like this malformations.
    Dotnet Training in Chennai

    ReplyDelete
    Replies
    1. I have read your blog its very attractive and impressive. I like it your blog.

      Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

      Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

      Delete
    2. Java Training Institutes Java Training Institutes Java EE Training in Chennai Java EE Training in Chennai Java Spring Hibernate Training Institutes in Chennai J2EE Training Institutes in Chennai J2EE Training Institutes in Chennai Core Java Training Institutes in Chennai Core Java Training Institutes in Chennai

      Delete

  3. Thanks for sharing in this post.I read your articles very excellent and the i agree our all points because all is very good information provided this through in the post.It is very helpful for me.
    DotNet Training in Chennai

    ReplyDelete

  4. Great and useful article. Creating content regularly is very tough. Your points are motivated me to move on.


    SEO Company in Chennai

    ReplyDelete
  5. Great article. I like it, Thanks for sharing.

    php training in chennai

    ReplyDelete
  6. Thank you for taking time to provide us some of the useful and exclusive information with us.
    Regards,
    dotnet courses in Chennai | .net training Chennai | .net course in Chennai

    ReplyDelete
  7. Hi welcome to this blog.really you have post an informative blog. itwill be really helpful to many peoples.thank you for sharing this blog.
    codedUI training

    ReplyDelete
  8. Android is an operating system for mobile devices. Its programs are built with python, c, c++ or Java programming language, but it User interface is always designed by Java and XML. Xml is abbreviated as extensible markup language.
    Android Course in Chennai | Android Training in Chennai

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. 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?

    ReplyDelete
  11. Thank you for taking time to provide us some of the useful and exclusive information with us.
    Regards, ty gia ngoai te hom nay, ncb, ty gia yen nhat

    ReplyDelete
  12. I Will Provide Seo Blog Comment Service. & niche relevant blog comment service we provide a quality service with 100% Buyer satisfaction and My team Believed in Quality work not Quantity Contact me Now 24/7.

    ReplyDelete
  13. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete