Skip to content
File cannot be loaded because running scripts is disabled

File cannot be loaded because running scripts is disabled

DodaTech 3 min read

The “File cannot be loaded because running scripts is disabled on this system” error means PowerShell’s execution policy is blocking your script from running.

What It Means

PowerShell’s execution policy is a safety feature that controls the conditions under which scripts can run. The default policy on Windows client systems is Restricted — scripts are not allowed to run at all, only individual commands. This prevents accidental execution of untrusted scripts but also blocks legitimate ones. The error message tells you the script path and the current policy in effect.

Why It Happens

  • The execution policy is set to Restricted (default on most Windows client systems).
  • The policy is AllSigned but your script is not digitally signed.
  • The script was downloaded from the internet and has the Mark-of-the-Web.
  • You are running in a constrained endpoint or AppLocker environment.
  • Group Policy overrides the local execution policy setting.
  • You are using PowerShell on a system managed by an organization with strict policies.

How to Fix It

1. Check your current execution policy

Get-ExecutionPolicy

# Possible values: Restricted, AllSigned, RemoteSigned, Unrestricted, Bypass

2. Set the execution policy to RemoteSigned (recommended)

# Run as Administrator
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

# Or system-wide
Set-ExecutionPolicy RemoteSigned

3. Bypass policy for a single script

# From Command Prompt or Run dialog
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\myscript.ps1"

# From PowerShell itself
powershell.exe -ExecutionPolicy Bypass -File .\myscript.ps1

4. Unblock a downloaded script

# Remove the Mark-of-the-Web
Unblock-File -Path .\myscript.ps1

# Then run normally
.\myscript.ps1

5. Sign your script with a code-signing certificate

# For AllSigned policy, scripts must be signed
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert
Set-AuthenticodeSignature -FilePath .\myscript.ps1 -Certificate $cert

6. Check for Group Policy overrides

# Machine-wide policy (may override local setting)
Get-ExecutionPolicy -Scope MachinePolicy

# User policy
Get-ExecutionPolicy -Scope UserPolicy
Does execution policy apply to all users?
Execution policy can be set at multiple scopes: MachinePolicy, UserPolicy, Process, CurrentUser, and LocalMachine. The effective policy is the most restrictive of all scopes. Group Policy settings (MachinePolicy / UserPolicy) always override local settings and cannot be changed without administrative privileges on the domain.
Is it safe to set execution policy to Bypass?
Bypass allows everything to run without restriction. It is useful for constrained environments like automated deployment pipelines or containers where scripts are tightly controlled. For daily use, RemoteSigned is the recommended balance — it allows local scripts and signed remote scripts while blocking unsigned scripts from the internet.
Does execution policy prevent me from running PowerShell commands?
No — execution policy only controls script files (.ps1, .psm1, .psd1). Individual commands typed at the prompt, run with -Command, or executed via Invoke-Expression are not blocked. This is why attackers often use -EncodedCommand — it bypasses execution policy entirely by sending commands as a parameter rather than a script file.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro