Windows 10 comes with a powerful command line tool that is the advance version of Windows DOS and have thousands of new features to control and automate a lot of task in Windows 10. This tool is called PowerShell. It is also available in all the Windows Server additions to provide automated tasks to be performed on the server easily.
You can use Windows PowerShell to perform day to day operations like setting up permissions on the folder to the level of setting up user accounts in Windows operating systems as well as Windows Servers operating systems.
By default, PowerShell scripting is not allowed to run on the Windows as a security feature. When you try to run the shell script you will get an error message saying “Script cannot be loaded because running scripts are disabled on this system”
With this error, you will not be able to execute the shell scripts on your computer and even you will not be able to test the self-created scripts on your computer.
Enable Shell Script Execution on Windows 10
To allow the execution of scripts on your computer, follow the following steps.
Click on the start menu and type PowerShell, the application will appear on the top, right click on it and run as Administrator.
Now run the command Get-ExecutionPolicy -List to see the current execution policy on the machine. As you can see that the execution policy is undefined for the current user as well as the local machine.
Now we will enable the current execution policy for the local machine so that any user of the computer can run shell scripting on the computer. Run the command Set-ExecutionPolicy Unrestricted -Scope LocalMachine and press enter.
It will show you the warning message that execution policy helps you to prevent scripts running that are not trusted. Do you want to change the execution policy? Type A and press enter.
Once enabled, now you can run the shell scripts on your computer. You can also verify the status of the execution policy by running the command Get-ExecutionPolicy -List
Now you can see that the execution policy for Local Machine set to Unrestricted which means that anyone can now run the scripts on the computer.