{"id":1280,"date":"2014-05-09T13:27:07","date_gmt":"2014-05-09T11:27:07","guid":{"rendered":"http:\/\/hen.co.za\/blog\/?p=1280"},"modified":"2014-05-09T14:03:20","modified_gmt":"2014-05-09T12:03:20","slug":"list-all-net-versions-using-powershell","status":"publish","type":"post","link":"https:\/\/hen.co.za\/blog\/2014\/05\/list-all-net-versions-using-powershell\/","title":{"rendered":"List all .Net versions using PowerShell"},"content":{"rendered":"<p>A quick tip (script) how to list all the .Net (major) versions of a list of machines.<\/p>\n<blockquote>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$serverListFile = &quot;&lt;Path to file&gt;\\computers.txt&quot;;\r\n$computers = Get-Content -path $serverListFile\r\n\r\n$BASEDOTNETPATH = &quot;\\c$\\Windows\\Microsoft.NET\\Framework\\&quot;\r\n\r\nfunction CheckNet45($computerName){\r\n  $NETROOTKEY = &quot;SOFTWARE\\\\Microsoft\\\\NET Framework Setup\\\\NDP\\\\v4&quot;\r\n  $keyname = $NETROOTKEY + &quot;\\\\Full&quot;\r\n  try{\r\n    $reg = &#x5B;Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(&quot;LocalMachine&quot;, $computerName)\r\n    if ($reg -ne $null){\r\n      if ($reg.OpenSubKey($keyname).GetValue(&quot;Version&quot;).ToString().StartsWith(&quot;4.5&quot;)){\r\n        return $True\r\n      }\r\n    }\r\n  }\r\n  catch {\r\n    #do nothing\r\n  }\r\n  return $False\r\n}\r\n\r\nforeach($computer in $computers)\r\n{\r\n  $computer\r\n  $ok = Test-Connection $computer -Count 1 -Quiet\r\n  if ($ok) {\r\n    $computerBasePath = &quot;\\\\&quot; + $computer + $BASEDOTNETPATH\r\n    $versionStr = &quot;&quot;\r\n    if (Test-Path ($computerBasePath + &quot;v1.0.3705&quot;)){\r\n      $versionStr = $versionStr + &quot;1.0,&quot;\r\n    }\r\n    if (Test-Path ($computerBasePath + &quot;v1.1.4322&quot;)){\r\n      $versionStr = $versionStr + &quot;1.1,&quot;\r\n    }\r\n    if (Test-Path ($computerBasePath + &quot;v2.0.50727&quot;)){\r\n      $versionStr = $versionStr + &quot;2.0,&quot;\r\n    }\r\n    if (Test-Path ($computerBasePath + &quot;v3.0&quot;)){\r\n      $versionStr = $versionStr + &quot;3.0,&quot;\r\n    }\r\n    if (Test-Path ($computerBasePath + &quot;v3.5&quot;)){\r\n      $versionStr = $versionStr + &quot;3.5,&quot;\r\n    }\r\n    if (Test-Path ($computerBasePath + &quot;v4.0.30319&quot;)){\r\n      $versionStr = $versionStr + &quot;4.0,&quot;\r\n\r\n      if (CheckNet45($computer)){\r\n        $versionStr = $versionStr + &quot;4.5,&quot;\r\n      }\r\n    }\r\n    $versionStr = $versionStr.TrimEnd(',')\r\n    &quot;\u00a0 Installed version(s): &quot; + $versionStr\r\n\r\n  }\r\n  else{\r\n   &quot; Is not pingable!&quot;\r\n  }\r\n}\r\n\r\n<\/pre>\n<\/blockquote>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A quick tip (script) how to list all the .Net (major) versions of a list of machines. $serverListFile = &quot;&lt;Path to file&gt;\\computers.txt&quot;; $computers = Get-Content -path $serverListFile $BASEDOTNETPATH = &quot;\\c$\\Windows\\Microsoft.NET\\Framework\\&quot; function CheckNet45($computerName){ $NETROOTKEY = &quot;SOFTWARE\\\\Microsoft\\\\NET Framework Setup\\\\NDP\\\\v4&quot; $keyname = $NETROOTKEY &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/hen.co.za\/blog\/2014\/05\/list-all-net-versions-using-powershell\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[7,240,279,24,278],"class_list":["post-1280","post","type-post","status-publish","format-standard","hentry","category-reference","tag-net","tag-powershell","tag-registry","tag-tip","tag-versions"],"_links":{"self":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/1280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/comments?post=1280"}],"version-history":[{"count":7,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/1280\/revisions"}],"predecessor-version":[{"id":1287,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/1280\/revisions\/1287"}],"wp:attachment":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/media?parent=1280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/categories?post=1280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/tags?post=1280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}