Files
m365auditor/POWERSHELL_ISSUE.md
Ivan Carlos de Almeida fb6ead25ee
Some checks failed
Build, Push, Publish / Build & Release (push) Failing after 2s
first load
2025-12-16 04:43:41 -03:00

5.1 KiB
Raw Blame History

How to Fix "Running Scripts is Disabled on this System" in PowerShell

PowerShell is blocking your script due to its execution policy settings, which are in place for security reasons. You can change these settings easily to allow your script to run.

  1. Open PowerShell as Administrator
    • Click Start, search for PowerShell.
    • Right-click and select Run as Administrator.
  2. Check Current Execution Policies
    • Run:
Get-ExecutionPolicy -List
- This displays the policies for each scope (see table below for explanations).
  1. Unblock Script Execution for Your User
    • To allow scripts for your user only (safest):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    - *RemoteSigned* allows scripts you write and scripts downloaded from the internet if they are signed.
  1. If You Need to Allow All Scripts (Less Secure)
    • Run:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
    - This will allow any script to run, regardless of source. Use only if you trust the scripts youre executing.
  1. Confirm Security Prompts
    • If prompted, press Y to confirm or type A (if asked) to accept all future changes1 2 3 .

If You Still Get the Error (Group Policy Enforced)

If changing the execution policy doesnt work, your system might have a Group Policy overriding this setting:

  • Press Win + R, type gpedit.msc, and press Enter.
  • Navigate to:
Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
  • Double-click Turn on Script Execution.
  • Set it to Enabled and choose Allow all scripts (or less permissive option if desired)1 4 .

Execution Policy Scopes Explained

Scope Description
MachinePolicy Enforced by Group Policy for entire machine
UserPolicy Enforced by Group Policy for current user
Process Applies only to current PowerShell session
CurrentUser Applies to scripts run by current Windows user
LocalMachine Applies to all users on the computer

Execution policies set at higher scopes (MachinePolicy, UserPolicy) override lower scopes (CurrentUser, LocalMachine)5 .

Quick Troubleshooting

  • If only running a script once, you can bypass the policy by running:
powershell -ExecutionPolicy Bypass -File .\mainscript.ps1
  • Use RemoteSigned or Unrestricted mindfully, as they lower script execution restrictions.

Note: Always revert your execution policy to the original or a safer state (such as Restricted) after running untrusted or experimental scripts for security6 5 .

References: Information sourced directly from Microsoft documentation and community troubleshooting discussions1 2 5 3 .