PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this sy
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的更多相关文章
- 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 ...
- PowerShell “execution of scripts is disabled on this system.”
Set-ExecutionPolicy RemoteSigned
- 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 ...
- jquery解决file上传图片+图片预览
js解决file上传图片+图片预览 demo案例中代码为js原生控制,可以根据项目的需求修改为jquery操作 <!DOCTYPE html><html lang="en& ...
- Powershell cannot be loaded because running scripts is disabled on this system 解决办法
问题背景 第一次跑ps时,出现了下面的提示.这是因为windows不允许执行脚本而已,不要大惊小怪. 解决办法 这个需要管理员执行,不然会出现以下的情况 正常情况
- ng : File C:\Users\baron\AppData\Roaming\npm\ng.ps1 cannot be loaded because running
一. Windos PowerShell 选择 管理员身份运行二.set-ExecutionPolicy RemoteSigned 然后更改权限为A 三.get-ExecutionPolicy 查看当 ...
- 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 ...
- 解决File.delete()删除不掉文件
首先注意两点: 此文件被使用的时候无法删除(比如网络输出没关闭流) 判断此文件是否存在再做删除(exists) 删除文件夹之前先删除文件夹下的所有文件(递归解决) 判断是否删除成功会有返回值,文件名错 ...
- 分享我编写的powershell脚本:ssh-copy-id.ps1
问:通过[字符串界面].如何从win,通过ssh,连接到sshd?答:在任意版本win中,通过cmd.exe,powershell.exe中调用ssh.exe,连接sshd. 问:通过[pow ...
随机推荐
- html5中使用标签支持视频播放
<!--定义视频--> <!-- <video src="E:/ext-4.2.1.883/learnHtml5/Wildlife.wmv" control ...
- stdout 与 stderr 的区别
stdout 与 stderr 的区别 一直没有注意 stdout 与 stderr 的区别,以为只是不同的描述方式.看来不是这样的. stdout 主要处理的是使用者输出 stderr 主要处理的错 ...
- GCC依赖库顺序问题
今天在把linux下做的ipmsg移植到windows过程中,因为包含了一个开源库SimpleSocket,而这个库又引用了winsock2,没太注意就写下了下面的makefile: g++ -o t ...
- 【模拟】XMU 1055 数七
题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1055 题目大意: 报数游戏,不能报7的倍数和2进制下含有111的数. 给定n,m(1& ...
- 64位操作系统 注册 capicom.dll
把capicom.dll 放到c:\windows\syswow64目录 以管理员身份运行c:\windows\syswow64\cmd.exe 执行 regsvr32 capicom.dll ...
- 黑马程序员_Java基础组成
Java语言基础组成 2.1关键字 main不是关键字,但被JVM所识别的名称. 关键字的定义和特点 定义:被Java语言赋予了特殊含义的单词. 特点:关键字中所有字母都为小写. 用于定义数据类型的关 ...
- UVa 11292 - Dragon of Loowater(排序贪心)
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shore ...
- 高性能web系统的架构和系统优化
07年毕业一直都在软件公司,14年来到一个互联网公司,给我的感受,区别主要在于: 软件公司需求相对稳定,能够按照计划按部就班的去实施,互联网公司需求相对来说不稳定,上线比较着急,大部分都是小迭代更新, ...
- Tomcat部署问题及解决方法
1.gradle构建web时报错:Access restriction: The type JPEGImageEncoder is not accessible due to restriction ...
- Asp.Net Webapi路由基本设置
1.直接在Global.asax中添加配置 如: using MvcApplication4.App_Start; using System; using System.Collections.Gen ...