In cygwin, I could just do ./script.sh args, but this opens the script file in notepad in PowerShell.
What do I need to do have it execute?
In cygwin, I could just do ./script.sh args, but this opens the script file in notepad in PowerShell.
What do I need to do have it execute?
There is now a "native" solution on Windows 10, after enabling Bash on Windows, you can enter Bash shell by typing bash:

You can run Bash script like bash ./script.sh, but keep in mind that C drive is located at /mnt/c, and external hard drives are not mountable. So you might need to change your script a bit so it is compatible to Windows.
Also, even as root, you can still get permission denied when moving files around in /mnt, but you have your full root power in the / file system.
Also make sure your shell script is formatted with Unix style, or there can be errors.

PowerShell. Perhaps, there are som pre-requisites you have not mentioned?cat /etc/lsb-release once inside the bash shell. So depending what you are doing, this may or may not be what you are looking for.You should put the script as argument for a *NIX shell you run, equivalent to the *NIXish
sh myscriptfile
sh is not included in vanilla Powershell. I had to install Git, which optionally adds some UNIX tools to the PATH in Powershell, sh.exe being one of them.sh , and there you can run unix/linux commands xD.It also can be run by exporting the bash and sh of gitbash C:\Program Files\git\bin\ to Windows' environmental variables.
In Advance section in the path var kindly add the C:\Program Files\git\bin\ which will make the bash and the sh of the git-bash to be executable from the window cmd.
Restart Powershell and then run the shell file as
bash shellscript.sh or sh shellscript.sh
If you add the extension .SH to the environment variable PATHEXT, you will be able to run shell scripts from PowerShell by only using the script name with arguments:
PS> .\script.sh args
If you store your scripts in a directory that is included in your PATH environment variable, you can run it from anywhere, and omit the extension and path:
PS> script args
Note: sh.exe or another *nix shell must be associated with the .sh extension.
PATH variable?Simplest Way (Windows10)
./your_script.sh
But you have to enable script running on PowerShell See Here
bash ./your_script.sh . I have a lot of files living on Windows that need to be copied to another directory, and your method allows it to occur faster.This is a variant of some of the other answers. It results in having your *.sh associated with the bash shell installed with Git, but without the hassle of having a Unix/Linux installation as with WSL.
It is common to have git as version control system nowadays. It is also quite common to use the git client provided by the git site. If you accept associating shell scripts to git bash during installation, you will not need any extra step: you already can run bash scripts from PowerShell.
When installing git, make sure to clear the checkbox "Only show new options" to have full control over the installation.
Then be sure to mark the checkmark "Associate .sh files to be run with Bash".
You are set.
Fom now on, you can run Bash sell scripts the same way as you run any other kind of file that has an executable associated:
An addition to the @Marius Tancredi's answer. You can run a bash command from PowerShell with:
bash -c "echo test"
WSL should be configured in Windows: https://learn.microsoft.com/en-us/windows/wsl/install