{"id":4022,"date":"2016-06-08T18:15:35","date_gmt":"2016-06-08T18:15:35","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=4022"},"modified":"2016-06-08T18:15:35","modified_gmt":"2016-06-08T18:15:35","slug":"environment-variables-in-powershell","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/environment-variables-in-powershell\/","title":{"rendered":"Environment variables in Powershell"},"content":{"rendered":"<p>This just demonstrates how, when you&#8217;re used to the standard Windows command prompt, Powershell can (at times) bite you.<\/p>\n<p>So I was getting some Java code configured and noticed the ant script listed a different JAVA_HOME to the one I expected. In a standard Windows command prompt I would type<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\necho %JAVA_HOME%\r\n<\/pre>\n<p>and ofcourse, expect to see the folder location. So this is what I did in Powershell and instead I just got the result %JAVA_HOME% written out.<\/p>\n<p>Powershell does things differently. In this case to output environment variables we need to use<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\necho $Env:JAVA_HOME\r\n<\/pre>\n<p>Doh!<\/p>\n<p>To set an environment variable in Powershell we simply type<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n$env:JAVA_HOME=&quot;C:\\Program Files\\Java\\jdk1.6.0_45&quot;\r\n<\/pre>\n<p><strong>References<\/strong><\/p>\n<p>See <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ff730964.aspx\" target=\"_blank\">Windows PowerShell Tip of the Week<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This just demonstrates how, when you&#8217;re used to the standard Windows command prompt, Powershell can (at times) bite you. So I was getting some Java code configured and noticed the ant script listed a different JAVA_HOME to the one I expected. In a standard Windows command prompt I would type echo %JAVA_HOME% and ofcourse, expect [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[118],"tags":[],"class_list":["post-4022","post","type-post","status-publish","format-standard","hentry","category-powershell"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=4022"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4022\/revisions"}],"predecessor-version":[{"id":4026,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4022\/revisions\/4026"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=4022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=4022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=4022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}