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.
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.
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.
‘gallery.technet.microsoft.com/scriptcenter/Detect-NET-Framework-120ec923’
Or depending on what version of PoSH you have installed, just ask PoSH directly.
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.
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.
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.
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.
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.
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.
Below is the output which I get were the $dcname information is missing.
is using .Net v4.6.2-Win 10 Anniversary Update
is using .Net v4.6.2-Win 10 Anniversary Update
is using .Net v4.5.1-Win 8.1
is using .Net v4.5.1-Win 8.1
Don’t see your code in here, but instead of all those IF…ElseIF might want to use a CASE statement instead to be neater.
Next since you are using invoke-command that is running on the remote server. So the variable $dcname is local to your computer and it does not exist on the remote computer. That is why it is blank.
Try using $env:computername instead of $dcname …
Good luck!
PS: I still think I prefer the PSCustomObject method. Offers more flexibility down the line.