PowerShell for Windows 7: Set-ExecutionPolicy for Regular Users

I want to run PowerShell scripts on Windows 7 as a regular user. Whenever I try, I get the following error:

File C:\Users\danv\Documents\WindowsPowerShell\profile.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:1 char:2 + . <<<< 'C:\Users\danv\Documents\WindowsPowerShell\profile.ps1' + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException 

Trying to solve using Set-ExecutionPolicy Unrestricted fails:

 PS C:\Users\danv> Set-ExecutionPolicy Unrestricted 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 

I can run the Set-ExecutionPolicy Unrestricted command as an administrator, but this does not seem to apply to non-admin users.

How can I successfully run scripts as a non-admin?

+52
windows-7 powershell
Jan 10 '11 at 13:44
source share
3 answers

If you (or a useful administrator) run Set-ExecutionPolicy as an administrator, the policy will be set for all users. (I would suggest "remoteSigned" instead of "unlimited" as a security measure.)

Note. On a 64-bit OS, you need to run Set-ExecutionPolicy for 32-bit and 64-bit PowerShell separately.

+59
Jan 10 2018-11-11T00:
source share
 Set-ExecutionPolicy Unrestricted -Scope CurrentUser 

This will set the execution policy for the current user (stored in HKEY_CURRENT_USER) and not the local machine (HKEY_LOCAL_MACHINE). This is useful if you do not have administrative control over the computer.

+99
Jan 19 '11 at 6:21
source share

This should solve your problem, you should try the following below:

 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser 
0
Jun 30 '16 at 18:20
source share



All Articles