I am running powershell to fetch running application. It works fine in Windows 7 but I got an error when I try to run it on Windows 10. Something about Authorization. This is the error
D:\\z.test\\getprocess.ps1 : File D:\\z.test\\getprocess.ps1 cannot be loaded. The file D:\\z.test\\getprocess.ps1 is not digitally signed. 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 . At line: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:
Set-ExecutionPolicy RemoteSigned
read about Powershell Execution Policy here
Please see this technet page:
https://technet.microsoft.com/en-us/library/ee176961.aspx
Powershell has a policy option on what scripts to run. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.