I am learning PowerShell and with all the video’s I saw I must say I am impressed. I have subscribed to the internal discussion group and the PowerShell team blog link.
Join me in my journey of exploring this new and powerful technology.
I took a script IPConfig.ps1 and saved it in C:\Temp folder. I executed it on my machine and this is what I saw.
Running it from Script Pane:
The Error clearly states.
File C:\Temp\IPConfig.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:0 char:0
Running it from the Command Pane:
I am happy that the man (help) pages are good. I mean it’s really really good.
The error is self explanatory, it clearly states the issue is “execution of scripts is disabled” on this system. When I type
PS C:\Temp> get-help about_signing
It gave me all the information I need to understand the ExecutionPolicy and how do I enable executing PowerShell scripts on my machine.
Ran the command:
PS C:\Temp> Set-ExecutionPolicy -ExecutionPolicy Unrestricted
And wow.. the script runs very well.
Going through the ExecutionPolicy I quickly learned that Unrestricted is not a good ExecutionPolicy neither in Production nor in Development machines. I changed it to the recommended RemoteSigned.
PS C:\Temp> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
The script is still happy to execute and I am happy to see my first step going good.
I will keep sharing my experience with PowerShell, the issues I come across and it's solution.