Get-Framework.NETVersion on remote computer by registry


posted by Sylvain LESIRE
12-05-2008

Downloads: 474
File size: 1.3kB
Views: 2,387

Embed
Get-Framework.NETVersion on remote computer by registry
  1. #------------------------------------------------------------------ 
  2. # Produces report for .NET Version on a set of remote computers or  
  3. # localhost 
  4. # 
  5. # Usage:  
  6. # local machine 
  7. # $env:computername | .\Get-FrameWork.NETVersion.ps1 
  8. # set of remote computers 
  9. #get-content <list of servers.txt> | .\Get-FrameWork.NETVersion.ps1 
  10. # 
  11. #        Optionally pipe output to Export-Csv, ConverTo-Html 
  12. #------------------------------------------------------------------ 
  13.  
  14. Process { 
  15. $Output = "" | Select ServerName , Application, Version, ServicePack 
  16.  
  17. $Srv =  $_ 
  18. $Output.ServerName = $Srv 
  19. $key = "SOFTWARE\Microsoft\NET Framework Setup\NDP" 
  20. $type = [Microsoft.Win32.RegistryHive]::LocalMachine 
  21. $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv
  22. $regKey2 = $regKey.OpenSubKey($key
  23.  
  24. Foreach($sub in $regKey2.GetSubKeyNames() 
  25.     ){ 
  26.     #$sub = .NET Version 
  27.     # subkey Path 
  28.     $subkey = "$key\$sub" 
  29.     $regKey3 = $regKey.OpenSubKey($subkey
  30.     Foreach($subkey in $regKey3.GetValueNames()){ 
  31.         # $subkey = key in key\sub 
  32.         if ($subkey -eq "SP") { 
  33.             $Output.Application = "Framework" 
  34.             $Output.Version = $sub.substring(0,4) 
  35.             $Output.ServicePack = $regKey3.GetValue("$subkey"
  36.             #Write-Host "Framework "$sub.substring(0,4) $subkey $regKey3.GetValue("$subkey") 
  37.             
  38.              
  39.         
  40.     $output 
  41.     
  42.      

This script permits to retreive version of Framework .NET by Powershell, by using registry.

 Please copy to file named Get-FrameWork.NETVersion.ps1

Usage to run script

On local machine
$env:computername | .\Get-FrameWork.NETVersion.ps1

a set of remote computers
get-content <list of servers.txt> | .\Get-FrameWork.NETVersion.ps1

        Optionally pipe output to Export-Csv, ConverTo-Html

 

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.