Changing the execution policy
By default, running any PowerShell script file has been forbidden and the following error will appear on the screen:
File D:\temp5\test.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
To view the current settings, run the following command
Get-ExecutionPolicy -List
To be able to execute .ps1 file using Powershell console or ISE, run the following command:
Set-ExecutionPolicy RemoteSigned
If you want to learn more about RemoteSigned, you have to do an Internet search.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-6
On the other hand, to execute the commands in a .ps1 file from any C# program, then, you don't need this.
File D:\temp5\test.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
To view the current settings, run the following command
Get-ExecutionPolicy -List
To be able to execute .ps1 file using Powershell console or ISE, run the following command:
Set-ExecutionPolicy RemoteSigned
If you want to learn more about RemoteSigned, you have to do an Internet search.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-6
On the other hand, to execute the commands in a .ps1 file from any C# program, then, you don't need this.
Comments
Post a Comment