How to check a specific version of .net present in all my DCs?

This topic contains 7 replies, has 4 voices, and was last updated by  Sammy Boy 2 days, 17 hours ago.

  • Author
  • #83984

    Sammy Boy

    Hi Friends,

    Here I'm again with a new question.

    I'm in bit of a trouble to find a proper script or way to know the version of .net installed in all my Domain Controllers in a forest.

    This even includes 2008 & 2008 R2 servers in it. As I'm still at beginner level into Powershell, I tried looking into forums & did a lot of googling to get some proper answers but unfortunately didn't get one yet.

    When I say all my DCs, my forest contain more than 3 hundreds of them.

    Can someone please help me here or guide me with some examples or to the right direction where I can get some assistance on this please.

    Peace & Cheers,
    Sammy Boy.

  • #83990

    Pradeep Arora

    One way to solve your problem is to use DSC to force a state of enabled / disabled of the required .Net versions on each of the DC from a single configuration file.

  • #83993

    Pradeep Arora

    One solution to your problem might be to use DSC and force all your DC to right version by setting the required state of a particular .Net version.

  • #84001


    As a POSH beginner, DSC is a bit much to bite off on.

    You can just poll the registry of each system to get this information.
    There are already existing scripts on the MS website for you to do such an effort. Just tweak as needed.

    Detect .NET Framework versions installed
    This script reports the various .NET Framework versions installed on the local or a remote computer. It queries the registry for the information (Remote Registry is required for querying the remote computers), and lists the .NET Framework version and it's build.

    # Or depending on what version of PoSH you have installed, just ask PoSH directly.

    ..but the registry if the most specific, because the above has come caveats.

    # or this way.

    Get-ChildItem -Path "$env:windir\Microsoft.NET\Framework\v*" |
    sort lastwritetime -desc |
    Format-Table -AutoSize

    Directory: C:\Windows\Microsoft.NET\Framework

    Mode LastWriteTime Length Name
    —- ————- —— —-
    d—- 11/11/2017 4:43 AM v4.0.30319
    d—- 9/14/2017 3:10 AM v2.0.50727
    d—- 4/19/2017 5:43 AM v1.0.3705
    d—- 4/18/2017 9:16 PM v3.5
    d—- 4/18/2017 8:29 PM v3.0
    d—- 8/22/2013 11:39 AM v1.1.4322

    If you need to update the .Net version, then software distribution / configuration efforts via GPO, System Center, DSC, etc. will get you there.

  • #84029


    So I used this script as a starting point. I won't share my script, it was a one and done. This has a lot of information and provide the details I think you need. Might need to update this script for any newer versions of .Net out there since.

    These links helped me find each version of .Net
    How to determine the .Net framework installed
    a. Matrix:

    If you are really stuck, I could share my script, but not sure it is ready for prim-time sharing. I think the first link with the function could be used against many servers if modified as necessary. Good luck.

  • #84040

    Sammy Boy

    Thank you friends for the all the help.

    This actually helps. I tried making my way with all your help (most of it is just copy-paste though) and still working to get the information in the way I need it.

    Something like the below one:

    $myForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $dclist = $myforest.Sites | % { $_.Servers }

    foreach ($dcname in $dclist) {
    # $source_dc_fqdn = ($dcname.Name).tolower()
    gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' |
    sort pschildname -des |
    foreach-object {$; $_.GetValue("Version");}

    The problem is that it does give me the list of all the versions & firmware installed on my remote DCs but doesn't give me information of the Hostname of the DCs against which they belong.

    @johnm: Please see if this is something which is included in your script already. If so, I'd love the helping hand here.

    Peace & Cheers,
    Sammy Boy

  • #84259


    OK. Not sure you are going to be able to do it the way you have it. .Net 4.x has a client and a Full version and the keys are slightly different (see second link above).

    What I did in my script was create a PSCustomObject with server name, and value. Then using the script linked above as a starting point, got the values and added them to the corresponding object property. Once they are in this object you can just write this to the Pipeline and/or do something with the results.

    So my Object looked like this

    $Obj = [PSCustomObject]@{ 
              'ServerName'  = $Null;
                   'Net10'  = $Null;
                   'Net20'  = $Null;
                   'Net30'  = $Null;
                   'Net35'  = $Null;
                   'Net40C' = $Null;
                   'Net40F' = $Null;

    loop thru your server list, add the server name to the $Obj.servername, query each of the reg keys, and populate your corresponding version $Obj value. Be sure to zap it at the top of your loop so missing values are not carried over from previous iterations.

    Sometimes you can just add the $Obj to an array, but really there is no good reason to do that. Use the pipeline instead.

    Good Luck!

  • #84535

    Sammy Boy

    Thank you all. I got what I needed.

    Thanks a ton. You guys rock!!

You must be logged in to reply to this topic.