[英]Powershell cannot be loaded on Windows10
I am running powershell to fetch running application. 我正在运行Powershell来获取正在运行的应用程序。 It works fine in Windows 7 but I got an error when I try to run it on Windows 10. Something about Authorization.
它在Windows 7中可以正常工作,但在尝试在Windows 10上运行时出现错误。 This is the error
这是错误
D:\\z.test\\getprocess.ps1 : File D:\\z.test\\getprocess.ps1 cannot be loaded.
D:\\ z.test \\ getprocess.ps1:无法加载文件D:\\ z.test \\ getprocess.ps1。 The file D:\\z.test\\getprocess.ps1 is not digitally signed.
文件D:\\ z.test \\ getprocess.ps1没有经过数字签名。 You cannot run this script on the current system.
您不能在当前系统上运行此脚本。 For more information about running scripts and setting execution policy, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170 .
有关运行脚本和设置执行策略的更多信息,请参阅http://go.microsoft.com/fwlink/?LinkID=135170上的 about_Execution_Policies。 At line:1 char:1 + D:\\z.test\\getprocess.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
在第1行:char:1 + D:\\ z.test \\ getprocess.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo:SecurityError:(: )[],PSSecurityException + FullyQualifiedErrorId:UnauthorizedAccess
What seems to be the problem here? 这里似乎是什么问题? Please help.
请帮忙。
Please see this technet page: 请参阅此technet页面:
https://technet.microsoft.com/en-us/library/ee176961.aspx https://technet.microsoft.com/en-us/library/ee176961.aspx
Powershell has a policy option on what scripts to run. Powershell对要运行的脚本具有策略选项。 The policy can be set to:
该策略可以设置为:
If you are happy to accept the security risks then run: 如果您乐意接受安全风险,请运行:
Set-ExecutionPolicy Unrestricted
However I recommend signing your scripts. 但是,我建议对脚本进行签名。 If you have a code signing certificate then you can sign your script using the following:
如果您具有代码签名证书,则可以使用以下命令来签名脚本:
$cert = Get-ChildItem cert:\CurrentUser\My\2C096472E989BA373512C307829E8E557A12BD93
Set-AuthenticodeSignature -Certificate $cert -FilePath C:\path_to_script.ps1
Replace C:\\path_to_script.ps1 with your path to your script you wish to sign and replace cert:\\CurrentUser\\My\\2C096472E989BA373512C307829E8E557A12BD93 with a path to your code signing certificate in the Windows certificate store. 将C:\\ path_to_script.ps1替换为您要签名的脚本的路径,并将cert:\\ CurrentUser \\ My \\ 2C096472E989BA373512C307829E8E557A12BD93替换为Windows证书存储区中代码签名证书的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.