Powershell

Is there a way to run a script in Powershell instead of CMD?

Honestly do not have any experience with PowerShell at all. Also do not use windows for many many years. So I can not be a big help here.

Anyway, it should be possible. Normally you can just β€œsend” data in a tool with something like β€œ<<” or similar (no idea how it works on windows exactly). But if you google you should find a solution.

Hey @Mizagog,

First, I realize that this is a 6 month old thread but I think that this is still valuable information.

So, PowerShell is available now for Linux and can execute scripts much like any other application. You simply need to prepend the command with pwsh.

For example, to run a command to produce the famous Hello, World! statement, in a PowerShell shell, you would enter:

Write-Host 'Hello, World!'

To execute this on a Linux system from a BASH prompt, you would enter this:

pwsh Write-Host 'Hello, World!'

Now, if you are attempting to execute a PowerShell script, all you need to enter from the BASH prompt is the name of the script. But, there is one big caveat to this. The script has to have a .ps1 extension! Otherwise, this will not work.

One last piece of advice. You also need to have PowerShell installed on your Linux box. :wink:

1 Like