Skip to content
Latchkey

PowerShell "running scripts is disabled on this system" in CI

PowerShell refused to run a .ps1 file because the effective execution policy is Restricted or AllSigned. The script content is fine; the policy blocks loading it.

What this error means

Invoking a script file fails immediately with an UnauthorizedAccess error pointing at the about_Execution_Policies help topic. The same script may run when pasted inline, because inline commands are not gated the same way.

powershell
.\build.ps1 : File C:\actions-runner\_work\repo\build.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Common causes

Execution policy is Restricted or AllSigned

A Restricted policy blocks all script files; AllSigned blocks unsigned ones. Calling a .ps1 directly under either policy fails before the script runs.

Calling a script file instead of inline commands

CI runners often allow inline pwsh blocks but not arbitrary script files. Switching from inline run: to .\script.ps1 hits the policy that the inline form bypassed.

How to fix it

Set the policy for the current process only

Scope the relaxation to the running process so it does not change the machine and resets when the step ends.

powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
.\build.ps1

Run the script via the interpreter with a bypass flag

Bypass the policy for one invocation without changing any persisted setting.

cmd
pwsh -NoProfile -ExecutionPolicy Bypass -File ./build.ps1

Use the workflow shell instead of a script file

  1. Put the commands inline under a pwsh: or powershell: step shell, which is not blocked by Restricted.
  2. Reserve .ps1 files for logic that must be reused, and call them with -ExecutionPolicy Bypass.

How to prevent it

  • Set the process execution policy once at the top of the job, or invoke scripts via pwsh -ExecutionPolicy Bypass -File so the policy never blocks a run.

Frequently asked questions

What causes ""running scripts is disabled on this system""?
A Restricted policy blocks all script files; AllSigned blocks unsigned ones. Calling a .ps1 directly under either policy fails before the script runs.
How do I fix "running scripts is disabled on this system"?
Scope the relaxation to the running process so it does not change the machine and resets when the step ends.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card