Windows PowerShell is a command-line shell and scripting language designed especially for system administration. Its analogue in Linux is called as Bash Scripting. Built on the .NET Framework, Windows PowerShell helps IT professionals to control and automate the administration of the Windows operating system and applications that run on the Windows Server environment. Windows PowerShell commands, called cmdlets, let you manage the computers from the command line. Windows PowerShell providers let you access data stores, such as the Registry and Certificate Store, as easily as you access the file system. In addition, Windows PowerShell has a rich expression parser and a fully developed scripting language. So in simple words, you can complete all the tasks that you do with GUI and much more. Windows PowerShell Scripting is a fully developed scripting language and has a rich expression parser. Recently one user got an issue while running a script, He created a script in the windows ISE power shell then while trying to run he got an error like
File C:\Common\Scripts\Basescript.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:13 + .\Basescript.ps1 <<<< + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException
So this guide will help you to resolve the issue and what is the reason for this issue.
Steps:
- Once you got the above-mentioned error open windows Power shell.
- Type windows Power shell on windows search, Right-click on windows Power shell, and select Run as admin. This will open the windows power shell in admin mode.
What is the reason for this error?
- By default, there is a policy assigned which block power shell scripts to run. So while running the script you can see the above-mentioned error. To remove this error first you check the policy is restricted or not.
- Open the power shell in admin mode and type the below-mentioned command.
get-executionpolicy
- This command will show the execution Policy is restricted or Not. As per the image the policy now restricted to enable this policy type below mentioned command.
Set-ExecutionPolicy unrestricted
Type [Y]–> yes
Type [A]–>yes To All
Type [N]–> NO
Type [L]–>No to All
Type [S]–>Suspend
Type A and hit enter. Now you can run any script you want.