# Windows coda: Running Powershell scripts from Ubuntu Bash

- Link: https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/
- Published: 2021-04-13T10:28:03-07:00
- Author: rich

Ok, I finally wrestled this one to the ground, but it is a little complicated and
unintuitive. First off, if the you have a Powershell script and it doesn’t need 
administrative mode, you have to run it this way. Hat tip to [Raymond](https://www.raymondcamden.com/2017/09/25/calling-a-powershell-script-from-wsl)
for this one.

    ```wp-block-code
    powershell.exe -File ".\install.ps1"
    ```

As should be obvious in retrospect, in WSL, you use forward slash but when calling
real Windows programs you use the backslash

Then if you need something to run with Administrative privileges, this is a real
pain in Windows. In the graphical interfaces, you have to right click on a command
in the Start menu and choose `Run as Administrator`, but if you want to do it from
a script you utter:

    ```wp-block-code
    runas.exe /savecred /user:some_user_name "powershell.exe -File .\install.ps1"
    ```

I’ll leave it for a reader to remember how to quote things, but basically, runas.
exe, unlike Bash, expects the whole thing in a single string.

The real run is what user account to use, the current easy default is that Windows
uses your Microsoft Account for login, but you cannot use that for this command.
There is a trope that says that if you switch your Windows account to a local account
and then create a local password and then switch it back again, then you can use
that local account password. This didn’t work at all for me.

Also note the `/savecred` this stores that password somewhere inside Windows so 
you don’t have to type it again.

### Share this:

 * [  Mastodon ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=mastodon)
 * [  LinkedIn ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=linkedin)
 * [  Facebook ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=facebook)
 * [  WhatsApp ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=jetpack-whatsapp)
 * [  Email ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?subject=%5BShared%20Post%5D%20Windows%20coda%3A%20Running%20Powershell%20scripts%20from%20Ubuntu%20Bash&body=https%3A%2F%2Ftongfamily.com%2F2021%2F04%2F13%2Fwindows-coda-running-powershell-scripts-from-ubuntu-bash%2F&share=email)
 * [More](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/#)

 * [  Telegram ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=telegram)
 * [  Print ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/#print?share=print)
 * [  Pinterest ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=pinterest)
 * [  Tumblr ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=tumblr)
 * [  X ](https://tongfamily.com/2021/04/13/windows-coda-running-powershell-scripts-from-ubuntu-bash/?share=twitter)

### Like this:

Like Loading…
