{"id":3801,"date":"2009-06-25T06:16:00","date_gmt":"2009-06-25T06:16:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2009\/06\/25\/detection-logic-for-powershell-installation\/"},"modified":"2019-02-18T13:12:32","modified_gmt":"2019-02-18T20:12:32","slug":"detection-logic-for-powershell-installation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/detection-logic-for-powershell-installation\/","title":{"rendered":"Detection logic for PowerShell installation"},"content":{"rendered":"<p>&#8220;How do we programmatically detect that PowerShell is installed ?&#8221; &#8211; This question has started coming up frequently as more folks (both internally and externally) have started to build applications with PowerShell support. As we approach <a title=\"Win7 release is close\" href=\"http:\/\/blogs.msdn.com\/e7\/archive\/2009\/05\/11\/OurNextEngineeringMilestone2.aspx\" target=\"_blank\">Win7\/W2K8-R2 release<\/a>,&nbsp;which will include <a title=\"PowerShell will be in-box in Win7 and W2K8-R2\" href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2008\/10\/28\/powershell-will-be-installed-by-default-on-windows-server-08-r2-ws08r2-and-windows-7-w7.aspx\" target=\"_blank\">PowerShell 2.0 in-box<\/a>, it is pertinent to have the right guidance out for PowerShell detection logic. If you&#8217;re writing an installer which&nbsp;relies on PowerShell presence, not only do you need to detect whether PowerShell is installed, but also&nbsp;what version of PowerShell is installed.<\/p>\n<ul>\n<li>\n<div>To check if <b><u>any version<\/u><\/b> of PowerShell is installed, check for the following value in the registry:<\/div>\n<\/li>\n<ul type=\"circle\">\n<li>Key Location: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1<\/li>\n<li>Value Name: Install<\/li>\n<li>Value Type: REG_DWORD<\/li>\n<li>Value Data: 0x00000001 (1<\/li>\n<\/ul>\n<\/ul>\n<ul>\n<li>To check <b><u>whether version 1.0 or 2.0<\/u><\/b> of PowerShell is installed, check for the following value in the registry:<\/li>\n<ul type=\"circle\">\n<li>Key Location: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\PowerShellEngine<\/li>\n<li>Value Name: PowerShellVersion<\/li>\n<li>Value Type: REG_SZ<\/li>\n<li>Value Data: &lt;1.0 | 2.0&gt;&nbsp; <\/li>\n<\/ul>\n<\/ul>\n<p>Remember:&nbsp;<\/p>\n<ul>\n<li>\n<div>Depending on any other registry key(s), or version of PowerShell.exe or the location of PowerShell.exe is not guaranteed to work in the long term.<\/div>\n<\/li>\n<li>\n<div>PowerShell 2.0 doesn&#8217;t support side by side installations with 1.0, but 2.0 is back-wards compatible with 1.0.<\/div>\n<\/li>\n<\/ul>\n<p>Hemant Mahawar [MSFT]<br \/>Program Manager<br \/>Windows PowerShell<\/p>\n<p>&lt;Updated&nbsp; 6\/26 to fix the spelling of PowerShell&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How do we programmatically detect that PowerShell is installed ?&#8221; &#8211; This question has started coming up frequently as more folks (both internally and externally) have started to build applications with PowerShell support. As we approach Win7\/W2K8-R2 release,&nbsp;which will include PowerShell 2.0 in-box, it is pertinent to have the right guidance out for PowerShell detection [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[73,287],"class_list":["post-3801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-installation","tag-releasedownload"],"acf":[],"blog_post_summary":"<p>&#8220;How do we programmatically detect that PowerShell is installed ?&#8221; &#8211; This question has started coming up frequently as more folks (both internally and externally) have started to build applications with PowerShell support. As we approach Win7\/W2K8-R2 release,&nbsp;which will include PowerShell 2.0 in-box, it is pertinent to have the right guidance out for PowerShell detection [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/3801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=3801"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/3801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=3801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=3801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=3801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}