Getting .NET 4.x Versions Using PowerShell

Not too long ago, we had to figure out which versions of .NET Framework Runtime were installed in our environment. It turns out it’s not difficult but not exactly straightforward either. I was expecting to find something out of the box in SCCM to cover this but I couldn’t find what I was looking for.

I then decided to turn to my old friend, PowerShell and create the script Get-NETFrameworkVersions.ps1 which is available in the GEM Automation CodePlex source code repository.

Here’s what the script does at a high level:

  1. Get a list of computers from the Active Directory (clients and servers, you might have to modify the filtering a bit for your environment)
  2. For each computer discovered from the Active Directory, start a PowerShell job that performs the following:
    1. Load the PSRemoteRegistry module which is required to query the registry keys containing the .NET Framework versions on the remote computers
    2. Check if the remote computer is online/reachable
    3. If the computer is online, check if the Remote Registry service is started, if not start it!
    4. Fetch registry keys from SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
    5. Export the result in a CSV file for the computer
  3. Once the discovery is complete, merge all of the computers CSV files into one file

A few things to note about the discovery process:

  • Versions prior to 4.x are not covered in this versions of the script
  • Discovery jobs launches are throttled to not overwhelm the computer running the script, you may need to adjust the number of concurrent jobs for your computer

With the CSV file in hand you can then perform analysis on the captured data using Excel.

Should you have questions/comments about this, feel free to drop a few words below!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s