问题描述
什么PowerShell脚本是返回的.NET框架版本的机器上?
What would a PowerShell script be to return versions of the .NET Framework on a machine?
我的第一个猜测是一些涉及WMI。有没有更好的东西?
My first guess is something involving WMI. Is there something better?
这应该是一个班轮为[每行]每个安装的.NET只返回最新版本。
It should be a one-liner to return only the latest version for each installation of .NET [on each line].
推荐答案
如果你要使用注册表,你必须为了得到完整的版本为4.0框架递归。早期的答案都返回我的系统上的.NET 3.0的根数(其中WCF和WPF的数字,是嵌套在3.0当中,是高 - 我无法解释这一点),并且无法为4.0返回任何东西..
If you're going to use the registry you have to recurse in order to get the full version for the 4.0 Framework. The earlier answers both return the root number on my system for .NET 3.0 (where the WCF and WPF numbers, which are nested under 3.0, are higher -- I can't explain that), and fail to return anything for 4.0 ...
这看起来我的权利(注意,单独的输出版本号为WCF和放大器; WPF的3.0,我不知道那是什么是什么。)。它也同时输出的客户和全部的在4.0(如果你有他们两个装):
This looks right to me (note that it outputs separate version numbers for WCF & WPF on 3.0. I don't know what that's about). It also outputs both Client and Full on 4.0 (if you have them both installed):
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { $_.PSChildName -match '^(?!S)\p{L}'} |
Select PSChildName, Version, Release
这篇关于PowerShell脚本返回.NET Framework版本的机器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!