计数字符串输出的实例

发布于 2025-02-09 06:15:04 字数 445 浏览 0 评论 0原文

我正在尝试计算服务器上特定dll的版本。找到我们拥有的版本相当容易,但是我想要每个版本的数量。这是我到目前为止的:

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

因此,如果上述输出:

1.2.3.4
1.2.3.4
1.2.3.4
5.6.7.8
9.0.1.2
9.0.1.2

我想要:我

1.2.3.4    3
9.0.1.2    2
5.6.7.8    1

想知道我该怎么做?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

享受孤独 2025-02-16 06:15:04

一种方法是:

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

它在我的计算机上的随机目录上给出:

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

更改&lt; top级折线&gt;incrude以适合您的情况。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文