One of the steps we have for setting up a new LSF server is to run a powershell script which does a survey of the machine. The first step is to un-restrict the execution policy via this command:
set-executionpolicy unrestricted
The command was entered and it returned this nice little error:
Execution Policy Change The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution policy? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft .PowerShell' is denied. At line:1 char:20 + set-executionpolicy <<<< unrestricted + CategoryInfo : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException, Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
Rather odd since all security was correct.
Two obvious ideas are to upgrade powershell or reinstall it. Neither was an option is this situation.
I did a quick look around Microsoft and found this.
I decided to try the registry option and added the login.
* Run: regedt32
* Goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell
* Right-Click > Permissions
* Select, and add your account, grant it “Full Control” privileges
I re-entered the set-executionpolicy command and this time it worked.