# Run a PowerShell Script from Terminal, CMD, or Run Dialog

> Execute PowerShell scripts using dot-source notation, full path with the call operator, or from CMD and the Run dialog, with execution policy troubleshooting

**URL:** https://sentry.io/answers/run-a-powershell-script/

---

## The Problem

I have a PowerShell script named `MyScript.ps1`. How do I execute it?

## The Solution

You can execute a PowerShell script by following these steps:

1. Launch Windows PowerShell as an Administrator. You should see a command-line window with a `PS>` prompt.
2. Navigate to the directory containing the script. For example:
    ```
    cd "C:\My Scripts"
    ```
3. Execute the script using `.\` syntax to tell PowerShell to look for the script in the current directory:
    ```
    .\MyScript.ps1
    ```

To run the script with a single PowerShell command from anywhere in the file system, you can specify the full path:

```
& "C:\My Scripts\MyScript.ps1"
```

Note that the path must be surrounded by quotation marks if it contains one or more spaces.

To run the script from Windows CMD or the Windows Run dialog, enter the following:

```
powershell -noexit "& ""C:\My Scripts\MyScript.ps1"""
```

Note that `&` in the above is the [call operator](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.4&viewFallbackFrom=powershell-7.1#call-operator-), which invokes the script.

If any of these methods produces an error indicating that the execution of scripts is disabled on your system, please see [this answer](https://sentry.io/answers/bypass-and-set-powershell-script-execution-policies/).

---

*Source: [sentry.io/answers/run-a-powershell-script/](https://sentry.io/answers/run-a-powershell-script/)*
