简体   繁体   English

无法在Windows10上加载Powershell

[英]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. 请帮忙。

Run PowerShell as Administrator and type: 以管理员身份运行PowerShell,然后键入:

Set-ExecutionPolicy RemoteSigned

read about Powershell Execution Policy here 在此处阅读有关Powershell执行策略的信息

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: 该策略可以设置为:

  • Restricted - No scripts can be run. 受限-无法运行任何脚本。 Windows PowerShell can be used only in interactive mode. Windows PowerShell只能在交互模式下使用。
  • AllSigned - Only scripts signed by a trusted publisher can be run. AllSigned-仅可运行由受信任的发布者签名的脚本。
  • RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run. RemoteSigned-下载的脚本必须先由受信任的发布者签名,然后才能运行。
  • Unrestricted - No restrictions; 无限制-无限制; all Windows PowerShell scripts can be run. 所有Windows PowerShell脚本都可以运行。

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.

相关问题 视窗10 | Powershell 重定向到 Microsoft 商店 - Windows10 | Powershell redirecting into Microsoft store Windows10 Powershell - 闹钟、世界时钟、计时器、秒表? - Windows10 Powershell - Alarm, World Clock, Timer, Stopwatch? 如何通过powershell访问windows10中的mdb文件? - How to access mdb file in windows10 by powershell? Windows10 / PowerShell:如何计算文件数,然后按子文件夹分类? - Windows10/powershell: how to count files and then sort them by subfolders? Cloudn't register-PSRepository 在我的 Windows10 中安装 Azure PowerShell - Cloudn't register-PSRepository in my Windows10 for installing Azure PowerShell 将 WiFi 切换 Linux shell 脚本翻译到 Windows10 CMD 或 Z3D265B4E13EEB10DDF17881FA0 - Translating WiFi switching Linux shell script to Windows10 CMD or PowerShell Windows10 / Powershell:使用Get-Childitem时如何使用-include参数? - Windows10/Powershell: How to use -include parameter when using Get-Childitem? 任务计划未执行可通过任务计划程序(Windows10)手动运行的Powershell脚本 - Task Scheduling not executing a Powershell script that can be manually run through Task Scheduler (Windows10) 无法在 Windows 10 上安装 fonts 和 Powershell - Cannot install fonts with Powershell on Windows 10 PowerShell5将index [0]设置为字符串的第一个实例,将index [1]设置为第二个实例,依此类推,直到在6800行Windows10批处理文件中完成 - PowerShell5 index[0] to the first instance of the string, index[1] to the second instance and so on till finished on a 6800 line windows10 batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM