The basic way to run a .ps1 file
To run a PowerShell script file, open PowerShell, navigate to the folder where your .ps1 file is stored, and type .\filename.ps1 (replacing "filename" with your actual script name). Press Enter. That's the core action — but Windows often blocks this by default, so you'll usually hit an error first.
The error you see is likely: "cannot be loaded because running scripts is disabled on this system." This is a execution policy — a safety feature that prevents accidental or malicious scripts from running. It's not a permanent lock, and you can change it for your current session without administrator rights.
Key Takeaways
- The command to run a script is .\scriptname.ps1, but Windows blocks script execution by default with an execution policy.
- You can bypass the block for your current PowerShell session only by running Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process first, then running your script.
- If you own the script file and trust it, you can also right-click it, select Properties, check "Unblock", and click Apply before running it.
- Never run scripts from sources you don't trust, even if someone tells you to change your execution policy permanently — the policy exists to protect you.
Unblocking a script file before running it
Windows marks files downloaded from the internet as "blocked" to prevent malware. You can see and remove this mark without changing any PowerShell settings. Right-click the .ps1 file, select Properties, and look at the bottom of the General tab. If you see a checkbox that says "Unblock", check it and click Apply, then OK.
After unblocking, you can run the script with .\filename.ps1 in PowerShell. This approach is safer than changing execution policies because it only affects that one file, and you're explicitly saying "I trust this script." If the file doesn't show an Unblock checkbox, it wasn't downloaded from the internet or it's already unblocked.
Changing execution policy for your current session
If unblocking doesn't work or you're running a script you created yourself, you can allow scripts to run just for your current PowerShell window. Type this command and press Enter:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
PowerShell will ask you to confirm. Type Y and press Enter. Now you can run your script with .\filename.ps1. This change only lasts while that PowerShell window is open — when you close it and open a new one, the restriction comes back. This is the safest middle ground because it protects you from accidentally running untrusted scripts in the future.
Understanding execution policies and when to change them
PowerShell has four main execution policies. Restricted (the default on most Windows machines) blocks all scripts. RemoteSigned allows scripts you created locally but blocks ones downloaded from the internet unless unblocked. Unrestricted allows all scripts but warns you about downloaded ones. Bypass allows everything with no warnings.
The reason these policies exist is real: a script can delete files, steal passwords, install malware, or change system settings. If someone online tells you to run a command that changes your execution policy to Unrestricted or Bypass permanently, that's a red flag. Permanent changes affect every script you run going forward, including ones you didn't write and don't understand. The safest approach is to use -Scope Process (current session only) or unblock individual files you trust.
Running scripts from a different folder
PowerShell won't run a script by typing just the filename — it needs to know where the file is. If your script is on your Desktop, you have two options. First, you can navigate to that folder in PowerShell by typing cd Desktop (or the full path), then run .\scriptname.ps1. Second, you can type the full path directly: C:\Users\YourUsername\Desktop\scriptname.ps1.
If the path has spaces in it (like "My Documents"), wrap the whole path in quotes: "C:\Users\YourUsername\My Documents\scriptname.ps1". Using the full path is often faster if you're only running one script and don't plan to run others from that folder.
Checking if a script ran successfully
When you run a script, PowerShell shows any output the script produces — text, tables, or error messages. If you see output and no errors, the script likely ran as intended. If you see red error text, something went wrong. Read the error message; it usually tells you what failed and why.
Some scripts run silently and produce no output at all, which is normal. If you're not sure whether a script did what it was supposed to do, check the relevant files or settings afterward. For example, if a script was supposed to create a file, look for that file in the location where it should be. If a script was supposed to change a setting, verify the setting changed.
Frequently Asked Questions
Can I run a .ps1 file by double-clicking it?
No. Double-clicking a .ps1 file opens it in Notepad or your default text editor instead of running it. You must run it from inside PowerShell using the .\filename.ps1 command. This is intentional — it prevents accidental execution of scripts you didn't mean to run.
What does the dot and backslash mean in .\filename.ps1?
The dot (.) means "the current folder" and the backslash (\) is the path separator. Together, .\ tells PowerShell "look for this file in the folder I'm currently in." Without it, PowerShell searches your system PATH instead, which usually won't find your script.
Is it safe to change execution policy to Unrestricted?
Not permanently. Unrestricted allows any script to run without warnings, which means malware or a script you didn't write could run silently. Use -Scope Process instead, which only affects your current PowerShell window. If someone tells you to set it to Unrestricted permanently, they're asking you to lower your security.
Why does my script run but nothing happens?
The script may have run successfully but produced no visible output. Check whether the script was supposed to create files, change settings, or display text. If it was supposed to do something you can verify (like create a folder), check whether that happened. If the script should have printed something, the script itself may need to be edited to include output commands.
Can I run a script with administrator rights?
Yes. Right-click PowerShell itself and select "Run as administrator", then navigate to your script and run it with .\filename.ps1. Some scripts need administrator rights to change system settings or access protected folders. Only do this for scripts you trust completely, since administrator scripts can make changes you can't easily undo.