Using PowerShell Core in PrimalScript
- Written by Alexander Riedel
- Last Updated: 20 August 2019
- Created: 15 September 2017
- Hits: 558
Back in May 2016, SAPIEN published an article 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 is 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.
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“.
- From the PrimalScript menu, click on “File“, and scroll-down to “Options“:
- Go to “File Groups“, to “Add New” PowerShell Core file groups:
- Go to “Command Window“, to add “New” Shell, and the “Rename” the “New Shell” name to “PowerShell Core 64 bit“:
- 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:
- 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.
- To execute the code, proceed to highlight a portion or the whole script.
- Right-click on the highlighted area, and select “Execute selection in PowerShell“.
- 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 a few limitations:
- Intellisense is meant for Windows PowerShell, so there might be some cmdlet parameters that won’t show.
- 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!