A quick tip (script) how to list all the .Net (major) versions of a list of machines.
$serverListFile = "<Path to file>\computers.txt";
$computers = Get-Content -path $serverListFile
$BASEDOTNETPATH = "\c$\Windows\Microsoft.NET\Framework\"
function CheckNet45($computerName){
$NETROOTKEY = "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4"
$keyname = $NETROOTKEY + "\\Full"
try{
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $computerName)
if ($reg -ne $null){
if ($reg.OpenSubKey($keyname).GetValue("Version").ToString().StartsWith("4.5")){
return $True
}
}
}
catch {
#do nothing
}
return $False
}
foreach($computer in $computers)
{
$computer
$ok = Test-Connection $computer -Count 1 -Quiet
if ($ok) {
$computerBasePath = "\\" + $computer + $BASEDOTNETPATH
$versionStr = ""
if (Test-Path ($computerBasePath + "v1.0.3705")){
$versionStr = $versionStr + "1.0,"
}
if (Test-Path ($computerBasePath + "v1.1.4322")){
$versionStr = $versionStr + "1.1,"
}
if (Test-Path ($computerBasePath + "v2.0.50727")){
$versionStr = $versionStr + "2.0,"
}
if (Test-Path ($computerBasePath + "v3.0")){
$versionStr = $versionStr + "3.0,"
}
if (Test-Path ($computerBasePath + "v3.5")){
$versionStr = $versionStr + "3.5,"
}
if (Test-Path ($computerBasePath + "v4.0.30319")){
$versionStr = $versionStr + "4.0,"
if (CheckNet45($computer)){
$versionStr = $versionStr + "4.5,"
}
}
$versionStr = $versionStr.TrimEnd(',')
" Installed version(s): " + $versionStr
}
else{
" Is not pingable!"
}
}
All you have to do is create a text file with a list of machine names (one name per line). It does assume you have Admin rights so you can access the C$ share and read the remote registries.