User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

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.

 

The Setup

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“:
    PrimalScript PSC 01 1
  2. Go to “File Groups“, to “Add New” PowerShell Core file groups:
    PrimalScript PSC 02 1
  3. Go to “Command Window“, to add “New” Shell, and the “Rename” the “New Shell” name to “PowerShell Core 64 bit“:
    PrimalScript PSC 03 1 PrimalScript PSC 04 1 PrimalScript PSC 05 1
  4. After all these changes are done, you’ll be asked to “..restart..” PrimalScript.
    PrimalScript PSC 06 1

 

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“.
    PrimalScript PSC 08 1 PrimalScript PSC 07 1
    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“.
    PrimalScript PSC 010 1
  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.
    PrimalScript PSC 011 1

 

Limitations

Remember, PrimalScript will let you create PowerShell Core script(s), but there are a few limitations:

  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:
Remove-Module PSReadLine

Now you can create and test your code without any problem.

Please, feel free to give it a try!

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.
Copyright © 2024 SAPIEN Technologies, Inc.