This topic is resolved

Share

This topic contains 11 replies, has 3 voices, and was last updated by  Paolo Maffezzoli 4 months, 1 week ago.

  • Author
    Posts
  • #163503
     Paolo Maffezzoli 
    Participant
    • Topics: 13
    • Replies: 38
    Post count: 124
    Member Points: 6,915

    I need to identify .NET Framework versions running on some machines.
    Can you suggest a way to detect the version using a Powershell script ?

    Any help is appreciated.

    Thanks!
    Paolo

    0
  • #163506
     Luc Fullenwarth 
    Moderator
    • Topics: 3
    • Replies: 24
    Post count: 83
    Member Points: 6,320

    Hi Paolo,

    You can put this one in a .PS1 file and then invoke it via Invoke-Command -File

    $computer=gc env:computername
    Get-ChildItem ‘HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP’ -recurse|
    Get-ItemProperty -name PSComputerName,Version,Release -ErrorAction 0|
    Where-Object { ($_.PSChildName -match ‘^(?!S)\p{L}’) -and ($_.PSChildName -notmatch “Foundation”) -and ($_.PSChildName -notmatch “Client”)}|
    Select-Object PSComputerName,PSChildName, Version, Release, @{
    name=”Product”
    expression={
    switch($_.Release) {
    378389 { [Version]”4.5″ }
    378675 { [Version]”4.5.1″ }
    378758 { [Version]”4.5.1″ }
    379893 { [Version]”4.5.2″ }
    393295 { [Version]”4.6″ }
    393297 { [Version]”4.6″ }
    394254 { [Version]”4.6.1″ }
    394271 { [Version]”4.6.1″ }
    }
    }
    }|
    Format-Table -AutoSize @{Label=”Computername”; Expression={$computer}},PSChildName, Version, Release, Product -HideTableHeaders

    • This reply was modified 4 months, 1 week ago by  Luc Fullenwarth. Reason: Visual formating
    • This reply was modified 4 months, 1 week ago by  Luc Fullenwarth. Reason: Added the file type
    0
  • #163527
     Luc Fullenwarth 
    Moderator
    • Topics: 3
    • Replies: 24
    Post count: 83
    Member Points: 6,320

    Just noticed that since I used this script, more versions have been issued 😀

    You can add following lines:

    394802 { [Version]”4.6.2″ }

    394806 { [Version]”4.6.2″ }

    460798 { [Version]”4.7″ }

    460805 { [Version]”4.7″ }

    More about here : https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

    3+

    Users who have liked this topic:

    • avatar
    • avatar
    • avatar
  • #164766
     Paolo Maffezzoli 
    Participant
    • Topics: 13
    • Replies: 38
    Post count: 124
    Member Points: 6,915

    Hi Luc,
    thank you for your information. Also the Microsoft How to doc is really helpful.

    1+

    Users who have liked this topic:

    • avatar
  • #164778
     Luc Fullenwarth 
    Moderator
    • Topics: 3
    • Replies: 24
    Post count: 83
    Member Points: 6,320

    You are welcome Paolo!

    0
  • #164801
     Mauro 
    Participant
    • Topics: 1
    • Replies: 5
    Post count: 15
    Member Points: 193

    $PSVersionTable.CLRVersion

    0
    • #164809
       Luc Fullenwarth 
      Moderator
      • Topics: 3
      • Replies: 24
      Post count: 83
      Member Points: 6,320
      • #166057
         Mauro 
        Participant
        • Topics: 1
        • Replies: 5
        Post count: 15
        Member Points: 193

        On a win7 with .net 4.6.1 and a win2016 $PSVersionTable.CLRVersion reports the same version:

        Major Minor Build Revision
        —– —– —– ——–
        4 0 30319 42000

        0
        • #166072
           Luc Fullenwarth 
          Moderator
          • Topics: 3
          • Replies: 24
          Post count: 83
          Member Points: 6,320

          Mauro, I don’t understand where you want to go with that…

          If you mean that $PSVersionTable.CLRVersion is a way to indentify the .Net Framework version,
          then I suggest that you contact Microsoft to update the official procedure with a far more easier method 🙂

          Here is the link:

          https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

          0
        • #166091
           Mauro 
          Participant
          • Topics: 1
          • Replies: 5
          Post count: 15
          Member Points: 193

          Hi luc,
          Sorry, i don’t mean to be cocky or rude.
          You’re right i’ve mistaken CLR with .NET:
          But if you query the Environment Class (as stated in the official documentation):
          “For the .NET Framework Versions 4, 4.5, 4.5.1, and 4.5.2, the Environment.Version property returns a Version object whose string representation has the form 4.0.30319.xxxxx.For the .NET Framework 4.6 and later, it has the form 4.0.30319.42000.”

          $ [System.Environment]::Version.ToString()
          4.0.30319.42000

          That’s the same info you get with $PSVersionTable.CLRVersion.ToString().

          I understand CLR and .NET are not the same thing but i was thinking that can be a “quick and dirty” way to check a remote pc.

          BTW: https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/versions-and-dependencies

          Thanks,
          Mauro

          0
        • #166106
           Luc Fullenwarth 
          Moderator
          • Topics: 3
          • Replies: 24
          Post count: 83
          Member Points: 6,320

          This works fine in your environment.
          I am currently in another one with versions earlier to version 4.

          I will continue to follow Microsoft’s recommendations which gives an accurate result in every environment.
          But don’t take care to me and use whichever method you find usefull for your environment. 🙂

          0
  • #168620
     Paolo Maffezzoli 
    Participant
    • Topics: 13
    • Replies: 38
    Post count: 124
    Member Points: 6,915

    Thank you Mauro and Luc for your answers.  Have a great day!

    Regards,

    Paolo

    0

You must be logged in to reply to this topic.

CONTACT US

Please ask IT administration questions in the forum. Any other messages are welcome.

Sending
© 4sysops 2006 - 2017

Log in with your credentials

or    

Forgot your details?

Create Account