---
title: "How to run a PowerShell script?"  
description: "How to run a PowerShell script?"  
author: "Utpal Vishwas"  
published: 2023-07-14  
updated: 2023-07-15  
canonical: https://www.mindstick.com/forum/159099/how-to-run-a-powershell-script  
category: "javascript"  
tags: ["scripting", "scripting language", "powershel"]  
reading_time: 2 minutes  

---

# How to run a PowerShell script?

How to run a [PowerShell](https://www.mindstick.com/forum/159436/powershell-script-executionpolicy-error-modify-policy) [script](https://www.mindstick.com/interview/477/how-can-i-execute-a-php-script-using-command-line)?

## Replies

### Reply by Aryan Kumar

There are several ways to run a PowerShell script. Here are the most common methods:

- **From the command prompt**

1. Open a command prompt.
2. Navigate to the directory where the script is located.
3. Run the following command:

```plaintext
powershell.exe -file <script_name>.ps1
```

For example, to run a script named `myscript.ps1`, you would run the following command:

```plaintext
powershell.exe -file myscript.ps1
```

- **From Windows PowerShell**

1. Open Windows PowerShell.
2. Navigate to the directory where the script is located.
3. Run the following command:

```plaintext
. <script_name>.ps1
```

For example, to run a script named `myscript.ps1`, you would run the following command:

```plaintext
. myscript.ps1
```

- **From the Run dialog box**

1. Open the Run dialog box.
2. Type the following command:

```plaintext
powershell.exe -file <script_name>.ps1
```

For example, to run a script named `myscript.ps1`, you would type the following command:

```plaintext
powershell.exe -file myscript.ps1
```

- **From the context menu**

1. Right-click the script file.
2. Select **Run with PowerShell**.

This will open a new PowerShell window and run the script.

The execution policy of PowerShell determines whether or not you can run scripts. By default, the execution policy is set to **Restricted**, which means that you cannot run scripts unless they are signed by a trusted publisher. If you want to run a script that is not signed, you need to change the execution policy.

To change the execution policy, you can run the following command:

```plaintext
powershell.exe -executionpolicy <policy_name>
```

For example, to change the execution policy to **Bypass**, you would run the following command:

```plaintext
powershell.exe -executionpolicy bypass
```

Once you have changed the execution policy, you can run the script.


---

Original Source: https://www.mindstick.com/forum/159099/how-to-run-a-powershell-script

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
