How to run scripts in powershell

Asked

Viewed 4,989 times

4

I have an extract.sh script that does some things. I have another powershell.sh script that makes the powershell call only. And inside the powershell.sh I pull the extract.sh to run the script inside the powershell. But when the powershell.sh script runs that opens the powershell, it stops right there...

My second scenario was to put the powershell command before the script started in the extract.sh script, but the result was the same...

So my question is: How I can call the powershell and run my script?

  • you could put an example of the codes of the scripts you want to run?

  • and how to run on linux??

  • @Pauloboaventura, https://docs.microsoft.com/pt-br/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1

2 answers

5


Powershell script files usually use the extension .ps1 and follow the specification of ligulate.

Following the premise that your script is written in powershell and your machine has powershell installed.

You can use the cmd.exe and type:

powershell seu-script.ps1

Using the powershell.exe and type:

.\seu-script.ps1

In addition powershell has a tool ISE (Integrated Script Environment) Powershell_ISE.exe.

Reply on thread in English: https://stackoverflow.com/questions/2035193/how-to-run-a-powershell-script/2035209

  • And how to run on Ubuntu ???

  • 1

    @Pauloboaventura you have to install by following the link: https://docs.microsoft.com/en-us/powershell/scripting/installing/powershell-core-on-linux?view=powershell-7.1

1

The Powershell comes restricted and it is only possible to execute a script by right clicking and asking to run by Powershell, or as the friend above informed executing the Powershell and calling the Script already inside the Powershell.

To change the Powershell execution policy we can use the following command as Administrator:

set-executionpolicy unrestricted

To check how this restriction use the following:

get-executionpolicy

Browser other questions tagged

You are not signed in. Login or sign up in order to post.