About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When PowerShell refuses a script with "File C:\Desktop\myscript.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.", an execution policy is stopping it. The policy can be set for the computer, for your user, for this session, or by Group Policy, and Microsoft documents which of them takes precedence.
Run one read-only command to see every scope, then change the narrowest scope that fixes your case. If Group Policy is the source, Set-ExecutionPolicy cannot help.
What the error means
Microsoft's page "Can't run scripts in Azure Active Directory module for Windows PowerShell" (dated 2026-01-15) lists this message among the symptoms, together with "The execution of scripts is disabled on this system" and "is not digitally signed". It gives two causes: the PowerShell version is higher than 5.1, because the Azure Active Directory module only works with PowerShell 3 to 5.1, and the execution policy is set to Restricted.
Microsoft's about_Execution_Policies page (dated 2026-08-31) says the execution policy "is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts" and "isn't a security boundary, it's defense in depth". Restricted "Permits individual commands, but doesn't allow scripts." The same page says that if the execution policy in all scopes is Undefined, "the effective execution policy is Restricted for Windows clients and RemoteSigned for Windows Server." It also calls RemoteSigned "The default execution policy for Windows computers", so read the output of the command below as the truth for your machine.
The scopes, in the order the page gives them:
- MachinePolicy: set by a Group Policy for all users of the computer.
- UserPolicy: set by a Group Policy for the current user.
- Process: affects only the current PowerShell session.
- CurrentUser: affects only the current user.
- LocalMachine: the default scope for
Set-ExecutionPolicy, affecting all users.
If Group Policy does not define the policy, the page gives the order of precedence as Process, then CurrentUser, then LocalMachine.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The effective policy is Restricted | Every script fails; individual commands work | Get-ExecutionPolicy -List shows Restricted, or Undefined everywhere on a Windows client |
| A Group Policy sets the policy | A Set-ExecutionPolicy command succeeds but the block continues |
MachinePolicy or UserPolicy in the list is not Undefined |
| A narrower scope overrides the one you changed | You set LocalMachine, but the user still cannot run scripts | CurrentUser or Process shows a stricter value |
| A downloaded script is blocked under RemoteSigned or AllSigned | The message says the file "is not digitally signed" instead | Get-Item -Stream "Zone.Identifier" lists a stream on the file |
Prove the cause before changing anything
All of these only read. Run them in the same PowerShell window, as the same user, that shows the error:
Get-ExecutionPolicy
Get-ExecutionPolicy -List
$PSVersionTable
Microsoft's page says Get-ExecutionPolicy gets the effective policy and Get-ExecutionPolicy -List lists the policies that affect the session and can "display them in precedence order", one row per scope. Write the whole list down, because the back-outs below depend on it. $PSVersionTable is the command the Entra page uses to identify the PowerShell version.
Microsoft's page also warns: "A command to change an execution policy can succeed but still not change the effective execution policy", for example when the current user's policy overrides the local computer's.
If the message is about a signature and the file came from the internet, check for the blocked mark:
Get-Item <path-to-script> -Stream "Zone.Identifier" -ErrorAction SilentlyContinue
Replace <path-to-script> with the script's path. The Unblock-File page uses Get-Item * -Stream "Zone.Identifier" to find files carrying the Zone.Identifier stream.
Example (illustrative): at contoso.com.au an administrator runs C:\Scripts\Get-DiskReport.ps1 on rds01 and gets the "running scripts is disabled" message. Get-ExecutionPolicy -List shows MachinePolicy Undefined, UserPolicy Undefined, Process Undefined, CurrentUser Undefined and LocalMachine Restricted. No Group Policy is involved, so a change at the scope the administrator controls will take effect.
Fix
Pick the narrowest scope that fixes your case. Process lasts only for the session, CurrentUser affects one user, and LocalMachine affects everyone on the computer. If a Group Policy scope is set, go to the last part of this section.
One session only: Process scope
Before you change it, record every scope as it stands:
Get-ExecutionPolicy -List
Risk: the next command lets this PowerShell window and the programs it starts run scripts under the policy you choose. Choose RemoteSigned, which Microsoft's page describes as requiring a digital signature from a trusted publisher on scripts downloaded from the internet. Do not use Bypass: Microsoft's page says with it "Nothing is blocked and there are no warnings or prompts."
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
Microsoft's page says a Process-scope policy "is retained until the current process and any child processes are closed" and is not stored in a configuration file. To undo it, close the window, or set Process back to the value the list above showed for it (Undefined if it showed Undefined):
Set-ExecutionPolicy -ExecutionPolicy <recorded-value> -Scope Process
One user: CurrentUser scope
Before you change it, record every scope, and note the CurrentUser value in particular:
Get-ExecutionPolicy -List
Risk: the next command changes the policy for your user account in every session you start from now on, until you change it back. It is saved in your configuration file.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
The Set-ExecutionPolicy page documents -Scope and a confirmation prompt; do not add -Force, which "Suppresses all the confirmation prompts". To undo it, set CurrentUser back to the value you recorded, using Undefined if the list showed Undefined:
Set-ExecutionPolicy -ExecutionPolicy <recorded-value> -Scope CurrentUser
Everyone on the computer: LocalMachine scope
Microsoft's page says to start PowerShell with Run as administrator for this scope. Before you change it, record every scope:
Get-ExecutionPolicy -List
Risk: the next command changes the policy for all users of this computer until it is changed back. Agree it with the server's owner first.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
To undo it, run the same cmdlet with -Scope LocalMachine and the value you recorded:
Set-ExecutionPolicy -ExecutionPolicy <recorded-value> -Scope LocalMachine
A downloaded script that is blocked
Under RemoteSigned the page says PowerShell "won't run unsigned scripts that are downloaded from the internet" until the file is unblocked. Microsoft's Unblock-File page says to verify the file and its source before you unblock it.
Before you change it, record that the file carries the stream, using the form from the Unblock-File page:
Get-Item <path-to-script> -Stream "Zone.Identifier"
Risk: the next command removes the Zone.Identifier stream that marks one file as downloaded from the internet, so PowerShell treats the file as local from then on. Run it only on a script whose source you have verified.
Unblock-File -Path <path-to-script>
To undo it: there is no way back from Unblock-File in Microsoft's pages.
A Group Policy sets the policy
Microsoft's page says the Turn on Script Execution Group Policy setting "overrides the execution policies set in PowerShell in all scopes". If you disable it, scripts don't run, which is equivalent to Restricted. The setting sits under Administrative Templates\Windows Components\Windows PowerShell, in Computer Configuration or User Configuration, and the Computer Configuration policy takes precedence. Change it only through the Group Policy that owns it, and with its owner's approval.
Confirm the fix
- Run
Get-ExecutionPolicyagain and check the effective value is the one you chose. - Run the script that failed. The message about running scripts should not appear.
- Run
Get-ExecutionPolicy -Listand compare the result with the list you recorded, so you can see exactly what changed.
What to watch afterwards
- A Group Policy refresh that puts the policy back. Microsoft's page says the Group Policy setting overrides PowerShell settings in all scopes.
- Scheduled tasks and services that run scripts as another account. CurrentUser applies to one user only.
- A different message about a signature after the first one clears, which points to the blocked-file case above.
Read next
Related articles you may want next.
- TroubleshootingInstall-Module "Unable to resolve package source" and "No match was found for the specified search criteria and module name"Install-Module says Unable to resolve package source, then No match was found. Enable TLS 1.2 in the session, then update PowerShellGet, with a way back.Read article
- TroubleshootingMicrosoft Graph PowerShell "Authorization_RequestDenied. Insufficient privileges to complete the operation."Microsoft Graph PowerShell returns Authorization_RequestDenied. Compare Get-MgContext scopes with Find-MgGraphCommand, then add the missing scope.Read article
- TroubleshootingPowerShell "The term is not recognized as the name of a cmdlet, function, script file, or operable program": the module is not loadedPowerShell says the term is not recognized as a cmdlet, function, script file or program. Check spelling, list modules, then import or install it.Read article
Risks and limits
These commands have not been run or lab-tested.
An execution policy is not a security boundary. Microsoft's page says users can bypass it by typing the script contents at the command line, so changing it controls convenience and accidents, not an attacker. Microsoft's execution-policy page describes pwsh.exe and gives no separate text for Windows PowerShell 5.1, so check Get-ExecutionPolicy -List for what your version reports. The Entra page recommends Set-ExecutionPolicy Unrestricted for its module and Set-ExecutionPolicy Restricted afterwards; the fixes above use the narrower scopes from the execution-policy page and do not recommend Unrestricted.
Two further facts from the execution-policy page matter on servers. On Windows Server Core and Windows Nano Server, PowerShell 6 can fail with "AuthorizationManager check failed" because PowerShell uses the Windows Desktop Shell to validate the zone of a script file and the shell is not available there. The page says an execution policy of Bypass or AllSigned "doesn't require a Zone check which avoids the problem". The same failure can occur on any Windows system when the shell is unavailable or unresponsive, for example when a PowerShell logon script starts before the desktop is ready. That is a different message from the one in the title, so do not use the steps above for it.
Sources
- Can't run scripts in Azure Active Directory module for Windows PowerShell — Microsoft Learn, page dated 2026-01-15, accessed 22 November 2026
- about_Execution_Policies — Microsoft Learn, page dated 2026-08-31, accessed 22 November 2026
- Set-ExecutionPolicy — Microsoft Learn, date not shown, accessed 22 November 2026
- Get-ExecutionPolicy — Microsoft Learn, date not shown, accessed 22 November 2026
- Unblock-File — Microsoft Learn, date not shown, accessed 22 November 2026
This article was originally published on .