Few usage scripts from my recent powershell
My Powershell execution findings for 32-Bit Operating Systems:
PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> H:\PROJECTS\PSLIB\Env.ps1
File H:\PROJECTS\PSLIB\Env.ps1 cannot be loaded because the execution of scripts is disable
d on this system. Please see "get-help about_signing" for more details.
At line:0 char:0
Reason:
The reason for this error is the security setting on your pc that does not allow you to execute a script. This is the so-called Execution Policy. By default, the Execution Policy is set to Restricted. This setting means that you may not run any PS1 script at all
Restricted: Individual cmdlets can run, but not saved Powershell scripts. This is the default setting
AllSigned: Scripts can run, but must have a digital signature even if written on the local computer. Prompts you before running scripts from trusted publishers.
RemoteSigned: Scripts written on the local computer do not need a digital signature, but any script downloaded from outside (email, IM, Internet) must have a signature to execute.
Unrestricted: Any script can run, but scripts downloaded from outside will run with a warning.
WORKAROUND:
Changing Execution Policy
The best way to set execution policy is to use the Set-ExecutionPolicy cmdlet. Set-ExecutionPolicy has one parameter – executionpolicy which can take one of four values:
Restricted
All Signed
Remote Signed
Unrestricted
Alternatively it is possible to edit the following registry key ExecutionPolicy value as Unrestricted
HKEY_Local_Machine\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.Powershell\ExecutionPolicy