Back in May 2016, SAPIEN did a blog post about “Using Bash with PrimalScript 2016“. 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’s early stages, you’ll have modify the console executable path each time you install the updated version of PowerShell Core: “C:\Program Files\PowerShell\x.0.0-xxxx-x“.
Another thing, PowerShell Core still is progressing in its Beta stage. So, SAPIEN won’t support any issues found with PowerShell Core until it reaches RTM status. If you find any issues with “PowerShell Core”, please send them directly to their Github link at:
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 “Command Window“.
1. From the PrimalScript menu, click on “File“, and scroll-down to “Options“:
2. Go to “File Groups“, to “Add New” PowerShell Core file groups:
3. Go to “Command Window“, to add “New” Shell, and the “Rename” the “New Shell” name to “PowerShell Core 64 bit“:
4. After all these changes are done, you’ll be asked to “..restart..” PrimalScript.
Executing the code
Before executing the code, you’ll need to open the PowerShell Core console:
1. From the menu, click on the “View” tab, then click on “Shell“, and under the “Console Window” select “PowerShell Core 64 bit“.
Now that the PowerShell Core console is open, anything that you select to execute will go to that active console.
2. To execute the code, proceed to highlight a portion or the whole script.
3. Right-click on the highlighted area, and select “Execute selection in PowerShell“.
4. As this will not complete executing the code, go to the “Console Window“, then press enter at the cursor line to execute the code manually.
Remember, PrimalScript will let you create PowerShell Core script(s), but there are few limitation:
1. Intellisense is meant for Windows PowerShell, so there might be some cmdlet parameters that won’t show.
2. Executing selected code block, at the “Command Window“, you’ll need to press enter to run the code.
The workaround for executing the code automatically, is to execute the following command:
Now you can create and test your code without any problem.
Please, feel free to give it a try!