How to run ps script?

PowerShell is a powerful scripting language that can be used by many applications, including Outlook and Exchange. For end-user use, it can be seen as the successor to vbs and batch scripts. If you are new to the PowerShell scripting language and learning how to run ps script, you have come to the right post PowerShell scripts in this guide Contains how to run PS scripts in relation to the use of. First of all in this article we will look at the prerequisites.


  • How to open powershell.
  • what happen when you use powershell first time.
  • Changing ps execution policy to set restricted policy.
  • Run PowerShell(ps) Script.
  • Easily execute a powershell script with some ways.

Below section we can expalin with details.

How to open powershell?

Powershell button A quick way to open powershell is the start menu icon then after opening the start menu or directly type “powershell” in the search box. Then it will be open.
In Windows 11, this entry has been replaced with Windows Terminal which opens Windows PowerShell sessions by default. Windows Terminal is also available for Windows 10.

What happen when you use powershell first time?

If you are trying to execute a Windows PowerShell script for the first time, you may run into a common problem. PowerShell will probably return an error message saying that a script “cannot be loaded because the script running on this system is disabled”.
PowerShell gives the above error message when you try to run powershell with the execution policy set to Restricted, Remote signed or All signed. If this is your first time using PowerShell, your default policy will probably be set to restrict all scripts. Because the default policy set for Windows client computers is restricted. You can execute individual commands in the terminal, but not a script file. The restriction includes .ps1xml, .psm1 or any file that ends with .ps1.

Changing ps execution policy to set restricted policy:

To change the execution policy then read these lines:

  • First, open PowerShell with Run as Administrator to make sure you have the highest permission to make the policy changes.
  • When open, run the following PowerShell command to set your computer’s execution policy. The execution policy, that can be one of three different types. This tutorial is using a useful yet still secure execution policy of RemoteSigned.
  • Assumes you’ve downloaded from the Internet the GetServices.ps1 script file, set the execution policy to RemoteSigned.
  • You should see an output requesting to confirm the action. Enter Y and hit enter to confirm the policy change.

Run PowerShell(ps) Script:

F‏irstly, you need to be able to run PowerShell as an administrator. You need to set your PowerShell execution policy to a permissive value or be able to bypass it. then use these steps and the details of these steps are given below:

  • Launch Windows PowerShell as an Administrator, and wait for the PS> prompt to appear.
  • Navigate within PowerShell to the directory where the script lives: PS> cd C:\my_path\yada_yada\ (enter)
  • Execute the script: PS> .\run_import_script.ps1

Or: you can run the PowerShell script from the Command Prompt (cmd.exe) like this:

powershell -noexit “& “”C:\my_path\yada_yada\run_import_script.ps1″”” (enter)

Simply execute a powershell script:

PowerShell Script Button The easiest way to execute PowerShell is to right-click and select scripts that allow direct execution. Run with powershell. If you only have code if the script needs to be loaded first or requires additional parameters, you can also use one of the following methods:

1. Using Console:

Once you have a script ready, there are a few different ways you can execute a PowerShell script file. One of the most common ways is via the PowerShell console.

To do so:

  • Firstly, Open the PowerShell console.
  • Navigate to the file system location your script is located using the Set-Location PowerShell cmdlet or the cd alias. PS> cd C:\Temp\
  • Run the script using a dot (.) notation. PowerShell is a shell that also looks for command names. To differentiate between a PowerShell command and a script, you must preface the script with a dot. This dot represents the current directory. PS> .\GetServices.ps1

2. Using File menu:

  • Browse to the location you stored the ps1-file in File Explorer and choose.
  • File-> Open Windows PowerShell
  • Type the name of the script.
  • Press TAB to autocomplete then name.
  • Press ENTER to execute the script. (Note: Do this even when you typed the name in full. This is because files within PowerShell need to start with a dot-slash ( .\ ) and pressing TAB will add that. Obviously, you can also manually type .\ in front of your filename but using TAB might be more convenient. The alternative is to type the file path in full.)

3. Using Drag & drop:

Follow these steps:

  • First of all, open a PowerShell window.
  • Then drag & drop the script from within File Explorer or from your Desktop into the PowerShell window.
  • Verify that the PowerShell window is active.
  • Press ENTER to execute the script.

4. Using command line:

If you can’t or would rather not run scripts via the PowerShell console, you can also do so with command prompt.

  • To run scripts via the command prompt, you must first start up the PowerShell executable (powershell.exe), with the PowerShell location of C:\Program Files\WindowsPowerShell\powershell.exe and then pass the script path as a parameter to it.
  • Once you open cmd.exe, you can execute a PowerShell script like below. This example is running the engine and passing it the script path of C:\Temp\GetServices.ps1.

In this article we have try to define “how to run ps script”. Hope you are like it! Thanks for reading this article.