Running a .ps1 file means telling PowerShell to open and execute the commands inside it

A .ps1 file is a text file containing PowerShell commands — think of it as a list of instructions you want PowerShell to run all at once instead of typing each one by hand. To run it, you open PowerShell, point it to the file's location, and use a command that tells PowerShell to read and execute what's inside. The most common method is typing a dot, a backslash, and the filename: .\filename.ps1

Windows has a safety feature called execution policy that blocks PowerShell scripts from running by default — this is intentional, to prevent malicious scripts from running without your knowledge. Before you can run your own .ps1 file, you may need to change this setting, but only for that one script or only for your user account, not for the whole computer.

Key Takeaways

  • The basic command to run a script is .\scriptname.ps1, typed in PowerShell from the folder where the file lives.
  • Windows blocks scripts by default through execution policy, so you may see an error the first time you try to run one.
  • You can allow a single script to run without changing your computer's settings by using the -ExecutionPolicy Bypass flag.
  • If you wrote the script yourself or trust where it came from, you can change your user's execution policy to allow scripts to run going forward.

Opening PowerShell in the folder where your script lives

PowerShell runs commands relative to wherever you are in the file system — so if your script is in C:\Users\YourName\Documents but PowerShell is looking at C:\Windows\System32, it won't find the file. The easiest way to avoid this is to open PowerShell already in the right folder.

In Windows 10 and 11, open File Explorer, navigate to the folder containing your .ps1 file, then right-click in the empty space and select Open PowerShell window here (or Open in Terminal if you're using Windows Terminal instead). PowerShell will open with that folder as your current location. Type dir and press Enter to see the files in that folder — your script should appear in the list.

If you don't see the PowerShell option in the right-click menu, you can open PowerShell any way you normally do, then use the cd command to navigate to the folder. For example: cd C:\Users\YourName\Documents then press Enter.

Running the script with the basic command

Once PowerShell is open in the correct folder, type the command exactly as shown: .\scriptname.ps1 — replacing scriptname with the actual name of your file. The dot and backslash (.\) tell PowerShell "look in the current folder for this file." Press Enter.

If the script runs, you'll see its output in the PowerShell window. If you see an error message that says "cannot be loaded because running scripts is disabled on this system", that's the execution policy blocking it. You have two options: allow just this one script to run, or change your execution policy permanently.

Allowing a single script to run without changing your settings

If you want to run this one script without changing anything on your computer, use the -ExecutionPolicy Bypass flag. Type this command: powershell -ExecutionPolicy Bypass -File .\scriptname.ps1 then press Enter. This tells PowerShell to ignore the execution policy just for this command, run the script, and then go back to the normal blocked state.

This method is useful if you're running a script you trust but don't plan to run scripts regularly. It doesn't change any settings, so your computer stays at the same security level. The script will run, and when it's done, PowerShell returns to blocking scripts again.

Changing your execution policy to allow your own scripts

If you write scripts yourself or regularly run scripts you trust, you can change your user's execution policy so PowerShell allows scripts to run without the bypass flag each time. This is a permanent change, but it only affects your user account — it doesn't change the policy for other people who use the computer.

Open PowerShell as Administrator: right-click the PowerShell icon and select Run as administrator. Then type this command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser and press Enter. PowerShell will ask you to confirm — type Y and press Enter.

The RemoteSigned policy means scripts you write or read from trusted sources can run, but scripts downloaded from the internet must be signed by a trusted publisher. This is a middle ground between blocking everything and allowing everything. After this change, you can run .\scriptname.ps1 without the bypass flag.

Understanding what the script does before you run it

Before running any .ps1 file, especially one you downloaded, open it in a text editor to see what commands it contains. Right-click the .ps1 file, select Open with, then choose Notepad or another text editor. You'll see the PowerShell commands inside — if you don't recognize what they do or they look suspicious, don't run the script.

Scripts can do anything PowerShell can do: delete files, change settings, install software, or access your network. If you downloaded a script from the internet, check where it came from and whether you trust that source. If someone sent you a script in an email or message, be especially cautious — this is a common way malware spreads.

Troubleshooting common errors

If you see "The term '.\scriptname.ps1' is not recognized", PowerShell can't find the file. Check that you're in the correct folder by typing dir and looking for your script in the list. Make sure the filename matches exactly, including capitalization and the .ps1 extension.

If you see "Access denied", the script may be marked as blocked by Windows. Right-click the .ps1 file in File Explorer, select Properties, and at the bottom of the window look for a checkbox that says Unblock. Check that box and click explore, then try running the script again.

If the script runs but nothing happens, it may have completed without producing visible output, or it may be waiting for input. Check the script in a text editor to understand what it's supposed to do. Some scripts create files or change settings without printing anything to the screen.

Frequently Asked Questions

Can I run a .ps1 file by double-clicking it in File Explorer?

No — double-clicking a .ps1 file opens it in a text editor instead of running it. You must open PowerShell and use the command line to execute it. This is intentional, to prevent accidental script execution.

What's the difference between RemoteSigned and Unrestricted execution policy?

RemoteSigned allows scripts you write or trust to run, but blocks scripts downloaded from the internet unless they're signed. Unrestricted allows all scripts to run with no restrictions. RemoteSigned is safer because it still blocks unsigned downloaded scripts.

Do I need to change execution policy on my work computer?

Your work computer may have execution policy set by your IT department, and changing it yourself could violate company policy or trigger security alerts. Ask your IT support team before running scripts on a work machine.

Will changing execution policy affect other programs?

No — execution policy only controls PowerShell scripts. It doesn't affect other programs, batch files, or anything else on your computer. It's specific to PowerShell.

What if the script needs to run as Administrator?

Some scripts require Administrator privileges to work. If you see an error about permissions, open PowerShell as Administrator (right-click and select Run as administrator) and run the script again from there.