0

I'm trying to count versions of a specific DLL on our servers. Finding what version we have is fairly easy, but I want a rolled up count of each one. This is what I have so far:

gci System.Web.Mvc.dll -Recurse -ErrorAction SilentlyContinue | 
select-object -ExpandProperty VersionInfo | 
Select FileVersion | 
sort-object { [string]$_.FileVersion }

So if the above output:

1.2.3.4
1.2.3.4
1.2.3.4
5.6.7.8
9.0.1.2
9.0.1.2

I'd want:

1.2.3.4    3
9.0.1.2    2
5.6.7.8    1

Any idea how I would do that?

1 Answer 1

2

One way to do it is:

(Get-ChildItem -Path <top-level-folder> -Include '*.dll' -Recurse).VersionInfo.FileVersion | 
    Group-Object $_ -NoElement |
    Sort-Object Count -Descending

Which, on a random directory on my machine, gives:

Count Name                     
----- ----                     
   12 4.700.19.56404           
    6 6.8.0.11012              
    6 1.0.0.0                  
    5 6.0.622.26602            
    4 2.1.1.0                  
    3 2.0.20168.4              
    3 6.3.1.0                  
    1 2.8.26.1919              
    1 6.0.222.6406             
    1 4.21.1.0                 
    1 1.2.3.0                  
    1 4.6.26919.2

Change the <top-level-folder> and the -Include to suit your situation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.