Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • VirtualBox
  • VMware
  • Windows
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • VirtualBox
  • VMware
  • Windows
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

PowerShell Script Cannot be Loaded Because Running Scripts is Disabled on This System

September 15, 2023
in Blog, Powershell
0
ADVERTISEMENT

Table of Contents

Windows Execution Policy

When trying to run a PowerShell script from the PowerShell console, we received this error message, and the script cannot be run.

nhLghp1HDaAM8KPsxhjCHuBYD43M00RssgcHyl50j15tzVCjDSGwZeLD0ukp

In some cases, it’s a The file is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy.

This is due to the Windows PowerShell execution policy being set to prevent untrusted scripts which can affect your Windows client environment. Execution policies are security settings that determine the trust level for scripts run in PowerShell. The default execution policy is Restricted on client operating systems like Windows 10/11, preventing scripts from running.

Note Note: On Windows server operating systems, the default execution policy is RemoteSigned.

You can check the current execution policy on your system using Get-ExecutionPolicy cmdlet. As you can see in the below screenshot, it’s configured to Restricted by default on Windows client operating system.

FGsvBxFQStFBChdfJQpUA42Xbieh359K4SJGXJHNaucKuL50nyyd2PvSPQ63

How to Fix Scripts is Disabled on This System

To fix it, let’s open Windows PowerShell as administrator then run the below command to set the execution policy to RemoteSigned

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force

Read more about the available execution policy on Windows machines from this post. Below is a quick snapshot about the execution policies.

You can also use Set-ExecutionPolicy Unrestricted to remove all restrictions on your security policy However, the RemoteSigned execution policy is the good option because it allows you to run all signed scripts downloaded from the internet and the scripts that you create manually on your computer. 

Once you have changed the execution policy, you should be able to run scripts without the error.

PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
PS C:\> Get-ExecutionPolicy
RemoteSigned
PS C:\> .\processes.ps1

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    117       8     1968       8132       0.17   3636   0 AggregatorHost
    330      20     8068      28592       0.64   7104   2 ApplicationFrameHost
    359      22     9512      30624       0.30   9204   1 ApplicationFrameHost
    289      15     4124      19312       0.06   9856   1 backgroundTaskHost
    480      20     1784       5700       0.47    644   0 csrss
    355      18     1928       5688       1.80    728   1 csrss
    435      20     1924       6248       1.30   5804   2 csrss
    392      16     3520      18924       1.48   3844   1 ctfmon
    392      16     3500      19136       1.34   4936   2 ctfmon
    144       9     1744      10136       0.16   1248   1 dllhost

Run scripts without admin rights

What if you can’t set the Execution Policy by running PowerShell as Administrator? To set the execution policy for the current user scope, use the following command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

The default scope is LocalMachine, which sets the policy for all users of the current machine. But the CurrentUser scope takes precedence. You can run the Get-ExecutionPolicy -List to get more details.

Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine      Restricted

Bypass ExecutionPolicy Temporarily for a Session

In case, if you want to run a script only once. You can bypass the execution policy just for a one-time session. In the command prompt, type the following command:

Set-ExecutionPolicy -ExecutionPolicy Bypass Process
PS C:\> Set-ExecutionPolicy -ExecutionPolicy Bypass Process
PS C:\> Get-ExecutionPolicy
Bypass
PS C:\> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process          Bypass
  CurrentUser       Undefined
 LocalMachine      Restricted

PS C:\> C:\Users\bonben\processes.ps1

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    117       8     1996       8152       0.25   3636   0 AggregatorHost
    334      20     8176      29040       0.70   7104   2 ApplicationFrameHost
    372      22     9528      29604       0.34   9204   1 ApplicationFrameHost
    460      19     1772       5656       0.80    644   0 csrss
    355      18     1884       5828       3.88    728   1 csrss
    447      20     2028       6312       2.38   5804   2 csrss
    405      16     3628      19064       2.17   3844   1 ctfmon
    408      16     3612      19276       1.47   4936   2 ctfmon
    149       9     1728      10420       0.17   1248   1 dllhost
    253      28     6552      15004       0.42   5624   1 dllhost

Once you close the PowerShell window, the current PowerShell session ends, and the Bypass is also closed with it. This allows you to run a PowerShell script temporarily while keeping the Execution Policy settings for all other PowerShell sessions. 

Note Tip: You can also copy-paste the script contents into the PowerShell console to bypass the execution policy.

When running the script in PowerShell ISE. You can bypass the execution policy by selecting a block of the script and then hitting F8 (Run Selection).

v9zjMi71F6mlhUayntb7SZZ4OXZcblB1npWjt3O7vsHdnBft1GlK8GQZAthY

Conclusion

The running scripts is disabled on this system error in PowerShell can be frustrating, but it is easily fixed by changing the execution policy. By understanding execution policies and following the steps outlined in this article, you can enable script execution and take advantage of PowerShell’s powerful automation capabilities.

Read more: How to Configure the PowerShell Execution Policy on Windows

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Always Open Windows Terminal Center on Screen

Next Post

How to Fix OneDrive Java Script Error on Windows 11

Related Posts

Ftr21

Export Microsoft 365 Disabled Users Report Using Microsoft Graph

December 7, 2023
Ftr22

Export List of Users with Managers Name and UPN in Microsoft 365

December 7, 2023
Ftr38

How to Split an Email Addresses From @ with PowerShell

December 5, 2023
Ftr38

[WinForms] Creating GUIs in Windows PowerShell with WinForms

November 15, 2023
Ftr21

Converting DateTime Obtained from Microsoft Graph Call to PowerShell Date and Time Format

October 21, 2023
Ftr21

How to Get Microsoft 365 License Expiration Dates using Graph Api

December 7, 2023

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to Enable Outlook Modern Authentication from Registry Setting
  • Export Microsoft 365 Disabled Users Report Using Microsoft Graph
  • Export List of Users with Managers Name and UPN in Microsoft 365

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2023 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory