{"id":13898,"date":"2017-09-15T06:00:57","date_gmt":"2017-09-15T13:00:57","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=13898"},"modified":"2017-09-14T14:31:54","modified_gmt":"2017-09-14T21:31:54","slug":"using-powershell-core-in-primalscript","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2017\/09\/15\/using-powershell-core-in-primalscript\/","title":{"rendered":"Using PowerShell Core in PrimalScript"},"content":{"rendered":"<p>Back in May 2016, SAPIEN did a blog post about &#8220;<a href=\"https:\/\/www.sapien.com\/blog\/2016\/05\/26\/using-bash-with-primalscript-2016\/\" target=\"_blank\" rel=\"noopener\">Using Bash with PrimalScript 2016<\/a>&#8220;.\u00a0 In a way, using similar steps, we can setup and use PowerShell Core in PrimalScript 2017 as well.<\/p>\n<p>Keep in mind, due to the fact that PowerShell Core still in it&#8217;s early stages, you&#8217;ll have modify the console executable path each time you install the updated version of PowerShell Core: &#8220;<strong><em>C:\\Program Files\\PowerShell\\x.0.0-xxxx-x<\/em><\/strong>&#8220;.<\/p>\n<p>Another thing, PowerShell Core still is progressing in its Beta stage. So, SAPIEN won&#8217;t support any issues found with PowerShell Core until it reaches RTM status. If you find any issues with &#8220;PowerShell Core&#8221;, please send them directly to their Github link at:<br \/>\n<a href=\"https:\/\/github.com\/PowerShell\/PowerShell\">https:\/\/github.com\/PowerShell\/PowerShell<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-weight: bold;\">The Setup<\/span><\/h3>\n<p>By default PrimalScript, will execute the PowerShell script(s) under Windows PowerShell. In order allow execution of PowerShell Core scripts, we need to add the PowerShell Core executable in their list of &#8220;<strong>Command Window<\/strong>&#8220;.<\/p>\n<p>1. From the PrimalScript menu, click on &#8220;<strong>File<\/strong>&#8220;, and scroll-down to &#8220;<strong>Options<\/strong>&#8220;:<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_01-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_01\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_01_thumb-1.png\" alt=\"PrimalScript_PSC_01\" width=\"448\" height=\"243\" border=\"0\" \/><\/a><\/p>\n<p>2. Go to &#8220;<strong>File Groups<\/strong>&#8220;, to &#8220;<strong>Add New<\/strong>&#8221; PowerShell Core file groups:<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_02-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_02\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_02_thumb-1.png\" alt=\"PrimalScript_PSC_02\" width=\"454\" height=\"210\" border=\"0\" \/><\/a><\/p>\n<p>3. Go to &#8220;<strong>Command Window<\/strong>&#8220;, to add &#8220;<strong>New<\/strong>&#8221; Shell, and the &#8220;<strong>Rename<\/strong>&#8221; the &#8220;<strong>New Shell<\/strong>&#8221; name to &#8220;<strong>PowerShell Core 64 bit<\/strong>&#8220;:<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_03-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_03\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_03_thumb-1.png\" alt=\"PrimalScript_PSC_03\" width=\"458\" height=\"227\" border=\"0\" \/><\/a><br \/>\n<a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_04-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_04\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_04_thumb-1.png\" alt=\"PrimalScript_PSC_04\" width=\"457\" height=\"227\" border=\"0\" \/><\/a><br \/>\n<a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_05-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_05\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_05_thumb-1.png\" alt=\"PrimalScript_PSC_05\" width=\"458\" height=\"224\" border=\"0\" \/><\/a><\/p>\n<p>4. After all these changes are done, you&#8217;ll be asked to <em>&#8220;..restart..&#8221;<\/em> PrimalScript.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_06-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_06\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_06_thumb-1.png\" alt=\"PrimalScript_PSC_06\" width=\"461\" height=\"213\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-weight: bold;\">Executing the code<\/span><\/h3>\n<p>Before executing the code, you\u2019ll need to open the PowerShell Core console:<\/p>\n<p>1. From the menu, click on the &#8220;<strong>View<\/strong>&#8221; tab, then click on &#8220;<strong>Shell<\/strong>&#8220;, and under the &#8220;<strong>Console Window<\/strong>&#8221; select &#8220;<strong>PowerShell Core 64 bit<\/strong>&#8220;.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_08-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_08\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_08_thumb-1.png\" alt=\"PrimalScript_PSC_08\" width=\"463\" height=\"281\" border=\"0\" \/><\/a><br \/>\n<a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_07-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_07\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_07_thumb-1.png\" alt=\"PrimalScript_PSC_07\" width=\"462\" height=\"159\" border=\"0\" \/><\/a><\/p>\n<p>Now that the PowerShell Core console is open, anything that you select to execute will go to that active console.<\/p>\n<p>2. To execute the code, proceed to highlight a portion or the whole script.<\/p>\n<p>3. Right-click on the highlighted area, and select &#8220;<strong><em>Execute selection in PowerShell<\/em><\/strong>&#8220;.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_010-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_010\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_010_thumb-1.png\" alt=\"PrimalScript_PSC_010\" width=\"465\" height=\"283\" border=\"0\" \/><\/a><\/p>\n<p>4. As this will not complete executing the code, go to the &#8220;<strong>Console Window<\/strong>&#8220;, then press enter at the cursor line to execute the code manually.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_011-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"PrimalScript_PSC_011\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/09\/PrimalScript_PSC_011_thumb-1.png\" alt=\"PrimalScript_PSC_011\" width=\"465\" height=\"302\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-weight: bold;\">Limitations<\/span><\/h3>\n<p>Remember, PrimalScript will let you create PowerShell Core script(s), but there are few limitation:<\/p>\n<p>1. Intellisense is meant for Windows PowerShell, so there might be some cmdlet parameters that won&#8217;t show.<br \/>\n2. Executing selected code block, at the &#8220;<strong>Command Window<\/strong>&#8220;, you&#8217;ll need to press enter to run the code.<\/p>\n<p>The workaround for executing the code automatically, is to execute the following command:<br \/>\n&#8220;<span style=\"color: #0000ff;\"><strong>Remove-Module PSReadLine<\/strong><\/span>&#8221;<\/p>\n<p>Now you can create and test your code without any problem.<\/p>\n<p>Please, feel free to give it a try!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Back in May 2016, SAPIEN did a blog post about &#8220;Using Bash with PrimalScript 2016&#8220;.\u00a0 In a way, using similar steps, we can setup and use PowerShell Core in PrimalScript 2017 as well. Keep in mind, due to the fact that PowerShell Core still in it&#8217;s early stages, you&#8217;ll have modify the console executable path [&hellip;]<\/p>\n","protected":false},"author":47,"featured_media":0,"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,"footnotes":""},"categories":[1143,410],"tags":[1215,1216],"class_list":["post-13898","post","type-post","status-publish","format-standard","hentry","category-powershell","category-primalscript-software-news","tag-powershell-core","tag-primalscript-2017"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/13898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=13898"}],"version-history":[{"count":5,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/13898\/revisions"}],"predecessor-version":[{"id":13923,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/13898\/revisions\/13923"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=13898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=13898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=13898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}