{"id":14409,"date":"2018-01-22T05:30:33","date_gmt":"2018-01-22T13:30:33","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=14409"},"modified":"2018-01-26T16:35:46","modified_gmt":"2018-01-27T00:35:46","slug":"sapien-tools-setup-wsl-bash-with-powershell-core-in-primalscript","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2018\/01\/22\/sapien-tools-setup-wsl-bash-with-powershell-core-in-primalscript\/","title":{"rendered":"SAPIEN Tools &#8211; Setup WSL Bash with PowerShell Core in PrimalScript"},"content":{"rendered":"<p>In this blog post, we examine setting up <strong>WSL<\/strong> (<em>Windows Subsystem for Linux<\/em>) &#8220;<strong>Bash with PowerShell Core<\/strong>&#8221; in <strong>PrimalScript&#8217;s<\/strong> &#8220;<strong>Console Window<\/strong>&#8221; list.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/HowToPSCore_01_2018-01-16_9-40-55-1.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"HowToPSCore_01_2018-01-16_9-40-55\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/HowToPSCore_01_2018-01-16_9-40-55_thumb-1.jpg\" alt=\"HowToPSCore_01_2018-01-16_9-40-55\" width=\"244\" height=\"70\" border=\"0\" \/><\/a><\/p>\n<h3>Prepare Bash File<\/h3>\n<p>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.<\/p>\n<p>1. In Windows 10 (Build 16299 or higher), from the start menu, open the Ubuntu Bash console.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_00_2018-01-16_18-24-37.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"BashPSCore_00_2018-01-16_18-24-37\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_00_2018-01-16_18-24-37_thumb.jpg\" alt=\"BashPSCore_00_2018-01-16_18-24-37\" width=\"396\" height=\"247\" border=\"0\" \/><\/a><\/p>\n<p>2. Use a Linux text editor (<strong>emacs24<\/strong> or <strong>vim<\/strong>) to create the following bash file as &#8220;<strong>pwsh-nonAdmin<\/strong>&#8220;, and save the file:<\/p>\n<p><strong><span style=\"color: #0000ff;\">&#8220;pwsh -NoExit -Command Remove-Module PSReadLine&#8221;<\/span><\/strong><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_01_2018-01-16_18-24-37.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"BashPSCore_01_2018-01-16_18-24-37\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_01_2018-01-16_18-24-37_thumb.jpg\" alt=\"BashPSCore_01_2018-01-16_18-24-37\" width=\"580\" height=\"134\" border=\"0\" \/><\/a><\/p>\n<p>3. Test by executing the Linux bash file \u201c<strong>pwsh-nonAdmin<\/strong>\u201d.<\/p>\n<p>&#8220;<strong><span style=\"color: #0000ff;\">bash \/home\/maxt\/pwsh-nonAdmin<\/span><\/strong>&#8221;<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_01a_2018-01-16_18-24-37.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"BashPSCore_01a_2018-01-16_18-24-37\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_01a_2018-01-16_18-24-37_thumb.jpg\" alt=\"BashPSCore_01a_2018-01-16_18-24-37\" width=\"586\" height=\"346\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Adding the Bash file to PrimalScript<\/h3>\n<p>Follow the same steps from this blog post:<br \/>\n<a href=\"https:\/\/www.sapien.com\/blog\/2018\/01\/17\/sapien-tools-how-to-work-with-powershell-core\/\" target=\"_blank\" rel=\"noopener\">SAPIEN Tools &#8211; How to work with PowerShell Core in PrimalScript<\/a><\/p>\n<p>In this case, I&#8217;ve selected my SAPIEN Technologies folder to save this DOS batch file*. Then, I manually entered this line in the \u201c<strong>Command Line<\/strong>\u201d field for the &#8220;<strong>New Shell<\/strong>&#8220;:<\/p>\n<p>&#8220;<strong><span style=\"color: #0000ff;\">bash \/home\/maxt\/pwsh-nonAdmin<\/span><\/strong>&#8221;<\/p>\n<p><em>*Note: Make sure to select a folder where this file is safely stored<\/em>.<\/p>\n<p>Then, follow the same steps from the <a href=\"https:\/\/www.sapien.com\/blog\/2018\/01\/17\/sapien-tools-how-to-work-with-powershell-core\/\">previous blog<\/a> to rename, save, restart, and test the command shell in <strong>PrimalScript&#8217;s<\/strong> \u201c<strong>Console Window<\/strong>\u201d.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_03_2018-01-16_18-24-37.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"BashPSCore_03_2018-01-16_18-24-37\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_03_2018-01-16_18-24-37_thumb.jpg\" alt=\"BashPSCore_03_2018-01-16_18-24-37\" width=\"603\" height=\"309\" border=\"0\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_04_2018-01-16_18-24-37.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"BashPSCore_04_2018-01-16_18-24-37\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_04_2018-01-16_18-24-37_thumb.jpg\" alt=\"BashPSCore_04_2018-01-16_18-24-37\" width=\"605\" height=\"249\" border=\"0\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_05_2018-01-16_18-24-37.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"BashPSCore_05_2018-01-16_18-24-37\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/01\/BashPSCore_05_2018-01-16_18-24-37_thumb.jpg\" alt=\"BashPSCore_05_2018-01-16_18-24-37\" width=\"609\" height=\"332\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Additional Tips<\/h3>\n<p>It is recommended to setup a second PowerShell Core to execute as &#8220;<em>Administrator<\/em>&#8220;, so the bash file may include the following line:<\/p>\n<p>&#8220;<strong><span style=\"color: #0000ff;\">sudo pswh -NoExit -Command Remove-Module PSReadLine<\/span><\/strong>&#8221;<\/p>\n<p>In the event that cross-platform script files are created, execute the Linux command &#8220;<strong>dos2unix<\/strong>&#8221; within Linux. This command will convert text files with DOS (or Mac) line breaks to Unix line breaks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we examine setting up WSL (Windows Subsystem for Linux) &#8220;Bash with PowerShell Core&#8221; in PrimalScript&#8217;s &#8220;Console Window&#8221; 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 [&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":[1115,1143,1238,410,1239],"tags":[],"class_list":["post-14409","post","type-post","status-publish","format-standard","hentry","category-bash","category-powershell","category-powershell-core","category-primalscript-software-news","category-pscore6"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/14409","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=14409"}],"version-history":[{"count":10,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/14409\/revisions"}],"predecessor-version":[{"id":14436,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/14409\/revisions\/14436"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=14409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=14409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=14409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}