{"id":7447,"date":"2020-05-07T14:55:05","date_gmt":"2020-05-07T18:55:05","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7447"},"modified":"2020-05-07T14:55:11","modified_gmt":"2020-05-07T18:55:11","slug":"get-installed-powershell-versions","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/","title":{"rendered":"Get Installed PowerShell Versions"},"content":{"rendered":"<p>As is the norm for a typical day, I was working on one thing when I was distracted by a shiny rabbit hole (to mix some metaphors). Half a day later I have a new PowerShell function that not only might you find useful, but I think it has some nice scripting features you might want to try yourself.<\/p>\n<p>The problem I had was to remotely query a Windows system and determine what versions of PowerShell were installed. For servers, you can use Get-WindowsFeature to check if PowerShell-V2 is installed. But what about PowerShell Core, PowerShell 7, or even a preview build? My solution was to query the registry.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7448\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry.png\" alt=\"ps-registry\" width=\"2172\" height=\"364\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry.png 2172w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry-300x50.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry-1024x172.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry-768x129.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry-1536x257.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry-2048x343.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ps-registry-850x142.png 850w\" sizes=\"auto, (max-width: 2172px) 100vw, 2172px\" \/><\/p>\n<p>Windows PowerShell uses different keys and property names than PowerShell Core, which includes PowerShell 7. Once I knew where to look, I could write a function. Because you can only query the registry on the \"local\" machine, my function would need to use PowerShell remoting. Here's the code, which is up on Github.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/jdhitsolutions\/d82d826d8a11319ff77e1578e7c8df06.js\"><\/script><\/p>\n<p>The function includes comment-based help.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7451\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1.png\" alt=\"get-psinstalled-help\" width=\"1939\" height=\"1086\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1.png 1939w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1-300x168.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1-1024x574.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1-768x430.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1-1536x860.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-help-1-850x476.png 850w\" sizes=\"auto, (max-width: 1939px) 100vw, 1939px\" \/>I wrote the function to accept computer names and credentials or an existing PSSession object. However, under the hood I'm only using PSSessions. If computer names are used, I create a temporary PSSession and add it to an array.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Process {\n        if ($PSCmdlet.ParameterSetName -eq 'computer') {\n            foreach ($computer in $Computername ) {\n                $PSBoundParameters[\"Computername\"] = $Computer\n                #create a session\n                Write-Verbose \"[$(New-TimeSpan -start $start) PROCESS] Creating a temporary PSSession to $($computer.toUpper())\"\n                If ($Credential.username) {\n                    Write-Verbose \"[$(New-TimeSpan -start $start) PROCESS] Using credential for $($credential.username)\"\n                }\n                Try {\n                    #save each created session to $tmp so it can be removed at the end\n                    $all += New-PSSession @PSBoundParameters -ErrorAction Stop -OutVariable +tmp\n                }\n                Catch {\n                    Write-Error $_\n                }\n            } #foreach computer\n        } #if computer parameterset\n<\/pre>\n<p>Note that when I create the session, I am saving it $tmp using Out-Variable. This is so that at the end of the command I can remove any sessions that I created. If a PSSession is passed, I add it to the array.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">foreach ($sess in $session) {\n                if ($sess.state -eq 'opened') {\n                    Write-Verbose \"[$(New-TimeSpan -start $start) PROCESS] Using session for $($sess.computername.toUpper())\"\n                    $all +=$sess\n                }\n            }\n<\/pre>\n<p>All of the sessions are added to an array of parameters which I splat to Invoke-Command.<\/p>\n<pre> Invoke-Command @icmParams<\/pre>\n<p>One thing that is different than what you might expect, is that this statement happens in the function's End scriptblock.\u00a0 This is because I want to rely on PowerShell to best manage all the connections. That's why I include the ThrottleLimit parameter which gets passed along to Invoke-Command. In earlier versions, I was piping PSSessions and running Invoke-Command in the Process scriptblock. This meant sessions were being processed one at a time. By moving the command to the End scriptblock, total processing time was cut almost in half. To summarize this point: the Process scriptblock is used for building a list of PSSessions. That's it.<\/p>\n<p>The Begin scriptblock is where I define the scriptblock to run remotely. I'm a big fan of using Write-Verbose in my commands. The potential obstacle though, is that if I run the function with -Verbose, when the scriptblock runs remotely, it doesn't know anything about my verbose preferences. Here's how I handle that.<\/p>\n<p>In the scriptblock, I add a parameter to indicate my Verbose preference.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$sb = {\n            param([string]$VerbPref = \"SilentlyContinue\")\n\n            $VerbosePreference = $VerbPref\n<\/pre>\n<p>In my function, I added a value to -Argumentlist that shows the verbose preference on <em>my<\/em> side.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$icmParams = @{\n            Scriptblock      = $sb\n            Argumentlist     = $VerbosePreference\n            HideComputerName = $True\n            ThrottleLimit    = $ThrottleLimit\n            ErrorAction      = \"Stop\"\n            Session          = $null\n        }\n<\/pre>\n<p>The last part of the verbose feature is that I'm using a running time as part of the message. I also indicate where in the function the statement is happening. In the scriptblock, my verbose messages employ $using to get the $start variable which is defined on my computer. I also use REMOTE to indicate the verbose message is happening elsewhere.<\/p>\n<pre>Write-Verbose \"[$(New-TimeSpan -start $using:start) REMOTE ] Querying \\\\$($env:computername)\\$pskey\"<\/pre>\n<p>Here's what it all looks like.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7453\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-verbose.png\" alt=\"get-psinstalled-verbose\" width=\"1163\" height=\"652\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-verbose.png 1163w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-verbose-300x168.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-verbose-1024x574.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-verbose-768x431.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-verbose-850x477.png 850w\" sizes=\"auto, (max-width: 1163px) 100vw, 1163px\" \/><\/p>\n<p>Now I can tell what is happening and where. Note that I aligned the leading portion of the verbose message. I find this makes it much easier to read.<\/p>\n<p>As for the result: nice and simple.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7454\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result.png\" alt=\"get-psinstalled-result\" width=\"1225\" height=\"323\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result.png 1225w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result-300x79.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result-1024x270.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result-768x203.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result-850x224.png 850w\" sizes=\"auto, (max-width: 1225px) 100vw, 1225px\" \/><\/p>\n<p>Or by specifying computer names.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7455\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png\" alt=\"get-psinstalled-result2\" width=\"1548\" height=\"361\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png 1548w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2-300x70.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2-1024x239.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2-768x179.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2-1536x358.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2-850x198.png 850w\" sizes=\"auto, (max-width: 1548px) 100vw, 1548px\" \/><\/p>\n\n\n<p>I have to say I'm pleased with the results. I hope you'll give it a try and let me know what you think. It should work in both Windows PowerShell and PowerShell 7.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As is the norm for a typical day, I was working on one thing when I was distracted by a shiny rabbit hole (to mix some metaphors). Half a day later I have a new PowerShell function that not only might you find useful, but I think it has some nice scripting features you might&#8230;<\/p>\n","protected":false},"author":1,"featured_media":7455,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Get Installed #PowerShell Versions via the Registry","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,110,8],"tags":[534,560,87,540],"class_list":["post-7447","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","category-registry","category-scripting","tag-powershell","tag-registry","tag-remoting","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Installed PowerShell Versions &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s my PowerShell function that uses remoting to query the registry to discover what versions of PowerShell are installed. Plus some scripting tips!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Installed PowerShell Versions &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s my PowerShell function that uses remoting to query the registry to discover what versions of PowerShell are installed. Plus some scripting tips!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-07T18:55:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-07T18:55:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1548\" \/>\n\t<meta property=\"og:image:height\" content=\"361\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Installed PowerShell Versions\",\"datePublished\":\"2020-05-07T18:55:05+00:00\",\"dateModified\":\"2020-05-07T18:55:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/\"},\"wordCount\":606,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/05\\\/get-psinstalled-result2.png\",\"keywords\":[\"PowerShell\",\"Registry\",\"remoting\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Registry\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/\",\"name\":\"Get Installed PowerShell Versions &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/05\\\/get-psinstalled-result2.png\",\"datePublished\":\"2020-05-07T18:55:05+00:00\",\"dateModified\":\"2020-05-07T18:55:11+00:00\",\"description\":\"Here's my PowerShell function that uses remoting to query the registry to discover what versions of PowerShell are installed. Plus some scripting tips!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/05\\\/get-psinstalled-result2.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/05\\\/get-psinstalled-result2.png\",\"width\":1548,\"height\":361},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7447\\\/get-installed-powershell-versions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Installed PowerShell Versions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Installed PowerShell Versions &#8226; The Lonely Administrator","description":"Here's my PowerShell function that uses remoting to query the registry to discover what versions of PowerShell are installed. Plus some scripting tips!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/","og_locale":"en_US","og_type":"article","og_title":"Get Installed PowerShell Versions &#8226; The Lonely Administrator","og_description":"Here's my PowerShell function that uses remoting to query the registry to discover what versions of PowerShell are installed. Plus some scripting tips!","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-05-07T18:55:05+00:00","article_modified_time":"2020-05-07T18:55:11+00:00","og_image":[{"width":1548,"height":361,"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png","type":"image\/png"}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Installed PowerShell Versions","datePublished":"2020-05-07T18:55:05+00:00","dateModified":"2020-05-07T18:55:11+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/"},"wordCount":606,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png","keywords":["PowerShell","Registry","remoting","Scripting"],"articleSection":["PowerShell","Registry","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/","name":"Get Installed PowerShell Versions &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png","datePublished":"2020-05-07T18:55:05+00:00","dateModified":"2020-05-07T18:55:11+00:00","description":"Here's my PowerShell function that uses remoting to query the registry to discover what versions of PowerShell are installed. Plus some scripting tips!","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png","width":1548,"height":361},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7447\/get-installed-powershell-versions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Get Installed PowerShell Versions"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/get-psinstalled-result2.png","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":7458,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7458\/a-powershell-remote-function-framework\/","url_meta":{"origin":7447,"position":0},"title":"A PowerShell Remote Function Framework","author":"Jeffery Hicks","date":"May 8, 2020","format":false,"excerpt":"The other day I shared a PowerShell function to query the registry on remote computers to find installed versions of PowerShell. The function leveraged PowerShell remoting with the flexibility of using a computer name with an optional credential or existing PSSessions. The more I thought about it, the more I\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/stop-remoteprocess.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":6348,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6348\/building-more-powershell-functions\/","url_meta":{"origin":7447,"position":1},"title":"Building More PowerShell Functions","author":"Jeffery Hicks","date":"January 3, 2019","format":false,"excerpt":"In a recent post I discussed the the process you might go through in developing a PowerShell function. By the end, I not only had a new tool for my PowerShell toolbox, but I had a function outline that I could re-use. If you read the previous article then you\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-3.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-3.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5734,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5734\/sending-files-to-your-browser-with-powershell\/","url_meta":{"origin":7447,"position":2},"title":"Sending Files to Your Browser with PowerShell","author":"Jeffery Hicks","date":"November 6, 2017","format":false,"excerpt":"Over the course of the last year I've been using markdown files much more, especially as part of the Platyps module. Even though I have a markdown editor and I can also preview files in VS Code, sometimes I want to see the file in my browser which has a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":953,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/953\/test-registry-item\/","url_meta":{"origin":7447,"position":3},"title":"Test Registry Item","author":"Jeffery Hicks","date":"October 4, 2010","format":false,"excerpt":"I've been doing some work lately involving the registry and Windows PowerShell. One of the tasks was to create new registry keys and entries. But because I wanted to some robustness, I wanted a way to verify if a given key or entry already existed. Using Get-ItemProperty is the easy\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1454,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1454\/teched-atlanta-managing-the-registry-with-powershell\/","url_meta":{"origin":7447,"position":4},"title":"TechEd Atlanta &#8211; Managing the Registry with PowerShell","author":"Jeffery Hicks","date":"May 23, 2011","format":false,"excerpt":"My second TechEd talk was about managing the registry with Windows PowerShell. If you were in the session you know that I stressed heavily using the PowerShell provider and cmdlets. For remote computers, leverage PowerShell's remoting infrastructure. But I also discussed using the \"raw\" .NET classes as well as WMI\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":455,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/455\/get-printer\/","url_meta":{"origin":7447,"position":5},"title":"Get-Printer","author":"Jeffery Hicks","date":"October 16, 2009","format":false,"excerpt":"I think Out-Printer is a very handy cmdlet, and one that doesn\u2019t get used much. Pipe any cmdlet to it and the output will be printed to your default printer. You use it the same way you would Out-File except output is printed instead of saved to a file. The\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=7447"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7447\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media\/7455"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}