Recently after a Windows Server 2008R2 implementation I had to use the new Microsoft Command Shell the so called “Windows PowerShell” to run a script. After installing the server I opened up notepad and wrote a simple script and as you’ll know I had to save the file with a PS1 extension so that PowerShell can execute the script. and I did save the file with the PS1 extension.
As soon as Opened PowerShell and typed the path to the PS1 file and press enter, I got an error as shown below
Which says “File <filepath> cannot be loaded because the execution of scripts is disabled on this system. Please see "get- help about_signing" for more details.”
If you get this error, don’t panic by default PowerShell is designed like this for security reasons, The Execution Policy which is in Windows PowerShell is set to Restricted which means none of the scripts will run (even if you write with your user credentials).
In Windows PowerShell type Get-ExecutionPolicy to verify
In order to be able to run scripts using Windows PowerShell type Set-ExecutionPolicy RemoteSigned
This would enable to run script using PowerShell on your computer