Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

In this article, we examine setting up WSL (Windows Subsystem for Linux) Bash with PowerShell Core in PrimalScript’s Console Window list.

Prepare Bash File

In order to open PowerShell Core in Linux, the bash shell needs to be open and pwsh should be run from the console. So, a bash file needs to be created to call Powershell Core.

1. In Windows 10 (Build 16299 or higher), from the start menu, open the Ubuntu Bash console.

BashPSCore_00_2018-01-16_18-24-37

 

2. Use a Linux text editor (emacs24 or vim) to create the following bash file as pwsh-nonAdmin, and save the file:

pwsh -NoExit -Command Remove-Module PSReadLine

BashPSCore 01 2018 01 16 18 24 37

 

3. Test by executing the Linux bash file pwsh-nonAdmin.

bash /home/maxt/pwsh-nonAdmin

BashPSCore 01a 2018 01 16 18 24 37

 

Adding the Bash file to PrimalScript

Follow the same steps from this article:
SAPIEN Tools – How to work with PowerShell Core in PrimalScript

In this case, I’ve selected my SAPIEN Technologies folder to save this DOS batch file*. Then, I manually entered this line in the Command Line field for the New Shell:

bash /home/maxt/pwsh-nonAdmin

*Note: Make sure to select a folder where this file is safely stored.

Then, follow the same steps from the article, SAPIEN Tools - How to Work with PowerShell Core in PrimalScript, to rename, save, restart, and test the command shell in PrimalScript's Console Window.

BashPSCore 03 2018 01 16 18 24 37

BashPSCore 04 2018 01 16 18 24 37

BashPSCore 05 2018 01 16 18 24 37

 

Additional Tips

It is recommended to setup a second PowerShell Core to execute as Administrator, so the bash file may include the following line:

sudo pswh -NoExit -Command Remove-Module PSReadLine

In the event that cross-platform script files are created, execute the Linux command dos2unix within Linux. This command will convert text files with DOS (or Mac) line breaks to Unix line breaks.

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.