code Download : The script mentioned in this article can be downloaded from the Microsoft Code base, how to determine versions & service pack levels of the. NET Framework by Powersh Ell
Case scenario
a very common scenario for you as a developer or IT Administrator is that you need to know which Microsoft. NET Framework versions are installed on your or customer's machine , and there are no better quick ways to get all of them . NET Framework version information?
Solution Solutions
The scheme is quite a lot ah, for example the following common:
using Windows Explorer get
- get
- command Prompt Run command-line program get
However, "there are thousands of flowers, I Only love one", today we introduce one and its useful another way, using PowerShell script to get The version number of the. NET Framework and SP service patch information.
The core principle of this script is also by reading the registry, but after all, not everyone has to deal with the registry every day, such as small, like me, face the Registry a bunch of information, it is two eyes a smear ah!!! So there is a direct script that can be run, it is more convenient ~ ~
Operational requirements
We have a request, the machine installed PowerSHell 2.0 that is must drop!
How do I use it?
- Go to Microsoft's official code base to download this script (very small,1.73K) -https:// gallery.technet.microsoft.com/how-to-determine-versions-d3669799 determinenetframeworkversion.ps1
- Open PowerShell as an administrator and run the following command:set-executionpolicy-executionpolicy remotesigned
- When prompted, enter a
- Right-click the script you just downloadeddeterminenetframeworkversion.ps1, in the security entry, click unblock < Span style= "font-family: ' Segoe UI '; FONT-SIZE:10PT, "lang=" X-none ">
< Span style= "font-family: ' Segoe UI '; font-size:10pt; "lang=" X-none ">< Span style= "font-family: ' Microsoft Yahei '; font-size:10pt; "lang=" X-none ">
5. Last Run script . \DetermineNe Tframeworkversion.ps1
Code Learning
For the retwist heart of the small apes, do not learn how to realize how to rest assured that:
Functionget-netframeworkversion {$RegistryPrefix="Registry::"; #4-clientTry {IF((Get-itemproperty-erroraction Stop-path ($RegistryPrefix+"hkey_local_machine\software\microsoft\net Framework setup\ndp\v4\client") | Select-expandproperty"Install")-eq1)-and(Get-itemproperty-erroraction Stop-path ($RegistryPrefix+"hkey_local_machine\software\microsoft\net Framework setup\ndp\v4\client") | Select-expandproperty"Version")-eq"4.0.30319.0") ) {Write-host". NET Framework 4-client"; }} Catch {}#4-fullTry {IF((Get-itemproperty-erroraction Stop-path ($RegistryPrefix+"hkey_local_machine\software\microsoft\net Framework setup\ndp\v4\full") | Select-expandproperty"Install")-eq1)-and(Get-itemproperty-erroraction Stop-path ($RegistryPrefix+"hkey_local_machine\software\microsoft\net Framework setup\ndp\v4\full") | Select-expandproperty"Version")-eq"4.0.30319.0") ) {Write-host". NET Framework 4-full"; }} Catch {}# ..... } Get-netframeworkversion
How to use PowerShell to list the version number and SP service patches for the. NET Framework on your machine