PowerShell 默认不允许执行*.ps1脚本文件。运行ps1文件会得到下面的错误:

File C:\Temp\Test.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:19
+ c:\Temp\Test.ps1 <<<<

可以通过Get-ExecutionPolicy,来取得当前策略。

用Set-ExecutionPolicy设置当前策略。

下面的命令可以解决上面的错误

PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned  <按回车>

Execution Policy Change

The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose

you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution

policy?

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):<按Y>

在PowerShell中的执行

Policy的有效参数:

-- Restricted:  不载入任何配置文件,不运行任何脚本。 "Restricted" 是默认的。

-- AllSigned: 只有被Trusted publisher签名的脚本或者配置文件才能使用,包括你自己再本地写的脚本

-- RemoteSigned:  对于从Internet上下载的脚本或者配置文件,只有被Trusted publisher签名的才能使用。

-- Unrestricted: 可以载入所有配置文件,可以运行所有脚本文件. 如果你运行一个从internet下载并且没有签名的脚本,在运行之前,你会被提示需要一定的权限。

-- Bypass: 所有东西都可以使用,并且没有提示和警告.

-- Undefined: 删除当前scope被赋予的Execution Policy.  但是Group Policy scope的Execution Policy不会被删除.

PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this sy的更多相关文章

  1. PS1--cannot be loaded because the execution of scripts is disabled on this system

    在nagiosXI上,通过nsclient++ 引用plugin “check_ms_win_disk_load”(https://outsideit.net/check-ms-win-disk-lo ...

  2. PowerShell “execution of scripts is disabled on this system.”

    Set-ExecutionPolicy RemoteSigned

  3. Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction policies

    Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction pol ...

  4. jquery解决file上传图片+图片预览

    js解决file上传图片+图片预览 demo案例中代码为js原生控制,可以根据项目的需求修改为jquery操作 <!DOCTYPE html><html lang="en& ...

  5. Powershell cannot be loaded because running scripts is disabled on this system 解决办法

    问题背景 第一次跑ps时,出现了下面的提示.这是因为windows不允许执行脚本而已,不要大惊小怪. 解决办法 这个需要管理员执行,不然会出现以下的情况 正常情况

  6. ng : File C:\Users\baron\AppData\Roaming\npm\ng.ps1 cannot be loaded because running

    一. Windos PowerShell 选择 管理员身份运行二.set-ExecutionPolicy RemoteSigned 然后更改权限为A 三.get-ExecutionPolicy 查看当 ...

  7. SharePoint 2007 Full Text Searching PowerShell and CS file content with SharePoint Search

    1. Ensure your site or shared folder in one Content Source. 2. Add file types. 3. The second step in ...

  8. 解决File.delete()删除不掉文件

    首先注意两点: 此文件被使用的时候无法删除(比如网络输出没关闭流) 判断此文件是否存在再做删除(exists) 删除文件夹之前先删除文件夹下的所有文件(递归解决) 判断是否删除成功会有返回值,文件名错 ...

  9. 分享我编写的powershell脚本:ssh-copy-id.ps1

      问:通过[字符串界面].如何从win,通过ssh,连接到sshd?答:在任意版本win中,通过cmd.exe,powershell.exe中调用ssh.exe,连接sshd.   问:通过[pow ...

随机推荐

  1. Spring中使用log4j随笔

    web.xml中的配置: <!--由Sprng载入的log4j配置文件位置--> <context-param> <param-name>log4jConfigLo ...

  2. html动态编辑框

    简述: 随着在输入框中增加字符,动态矿高度增加(IE9及以上 chrome  firefox) 由于IE8 不支持oninput函数,所以不能实现此效果 事件函数: function feedDivO ...

  3. VirtualBox - 自动调整屏幕大小,显示分辨率

    在VirtualBox中安装了Ubuntu后,Ubuntu的屏幕调整不太好,操作起来非常不方便,需要安装Vbox的增强功能.具体如下:1, 在  设备--> 安装增强功能这时会自动加载VBOXA ...

  4. tinyxml开源库的基本用法

    最近项目中的某个功能需要写xml,由于项目中已经引入了tinyxml,所以不再寻找其他开源库. 前提:你得有个xml对象,声明tinyxml的对象:基于tinyxml的内存管理,TiXmlDocume ...

  5. HDOJ(HDU) 1877 又一版 A+B(进制、、)

    Problem Description 输入两个不超过整型定义的非负10进制整数A和B(<=231-1),输出A+B的m (1 < m <10)进制数. Input 输入格式:测试输 ...

  6. XBox360自制系统的更新(Update)

    升级和更新 升级(Upgrade):从Windows XP到Windows 10,这叫升级,不叫更新.XBox360升级失败的话,后果可能会比较严重,直接就无法开机了. 更新(Update):在Win ...

  7. ObsoleteAttribute 可适用于除程序集、模块、参数或返回值以外的所有程序元素。 将元素标记为过时可以通知用户:该元素在产品的未来版本中将被移除。

    官方文档:https://msdn.microsoft.com/zh-cn/library/system.obsoleteattribute(v=vs.110).aspx 备注 ObsoleteAtt ...

  8. 《算法问题实战策略》-chaper14-整数论

    Lucas定理: 在组合计数问题中,我们常面临组合数C(n,m)过大而无法直接计算的困境,那么这里的Lucas定理给出了一个较大组合数进行取余运算的一种递归算法. 什么是Lucas定理? Lucas定 ...

  9. Python之路【第一篇】:Python前世今生

    Python简介 Python前世今生 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解 ...

  10. Tomcat的错误 之 java.lang.IllegalArgumentException: Document base * does not exist

    Tomcat的异常 之 java.lang.IllegalArgumentException: Document base 有些刚开始使用的Tomcat的朋友会出现的问题,明明已经将某个web应用从t ...