Use PowerShell to find all instances of a DLL

Eventually, if you do enough .NET development, you will find yourself in a situation where your application is complaining because it cannot find the right version of a DLL. You could always try to do a search of your hard drive and find these DLLs, but why do it the hard way? Easily enough, you can just use PowerShell to find all instances of a DLL on your computer, which can help you try to track down issues like this.

Here is the PowerShell command that will show you all of the folders, dates, and versions of a DLL that starts with “newtonsoft”. Make sure to substitute in the name of the DLL you are searching for, that you start in the folder that you want to execute the search from (or in other words, if you want to search your entire hard drive, make sure to change directory to the root of your C: drive first), and it can help if you run the PowerShell application as an administrator if you can.

Get-Childitem -Recurse newtonsoft*.dll | Format-Table directory,creationtime,lastwritetime,@{label="ProductVersion";expression={$_.versioninfo.productversion}},@{label="FileVersion";expression={$_.versioninfo.fileversion}}

Or, if you want a listing with fewer columns, try this one:

Get-ChildItem -Recurse newtonsoft*.dll | Format-Table directory,@{label="FileVersion";expression={$_.versioninfo.fileversion}},lastwritetime

BTW, a posthumous Happy Birthday to Dennis Ritchie, a legend in the software development community.

Leave a Reply