scripts is disabled on this system error in PowerShell

 

File cannot be loaded because the execution of scripts is disabled on this system error in PowerShell



When you try to run a Powershell script (PS1), you may get the following error:

File xyz.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details. At line:1 char:2

The reason for this error is the security setting on your pc that does not allow you to execute a script.  This is the so-called Execution Policy. By default, the Execution Policy is set to Restricted. This setting means that you may not run any PS1 script at all.

An overview of the policy levels:

Restricted: Individual cmdlets can run, but not saved Powershell scripts. This is the default setting.
AllSigned: Scripts can run, but must have a digital signature even if written on the local computer. Prompts you before running scripts from trusted publishers.
RemoteSigned: Scripts written on the local computer do not need a digital signature, but any script downloaded from outside (email, IM, Internet) must have a signature to execute. 
Unrestricted: Any script can run, but scripts downloaded from outside will run with a warning.

If you’re working on a desktop and just experimenting with PowerShell, the best is to set the policy-level to Unrestricted. This allows you do everything with annoying security boundaries. Just be careful not to run every script you download from the internet :)
If you’re working in a production environment and only want to run self-written scripts, the RemoteSigned level should be loosy enough.

To change the Execution Policy to Unrestricted, type the following command in Powershell

Set-ExecutionPolicy Unrestricted

To change the Execution Policy to RemoteSigned (to run your own scripts), type the following command in Powershell

Set-ExecutionPolicy RemoteSigned

If you have any question left, feel free to leave a comment. By choosing to be informed when someone posts a reply, you will immediately receive an email after someone replies.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值