VMware Cloud Community
dwchan
Enthusiast
Enthusiast
Jump to solution

ps1 script cannot be loaded because the execution of scripts is disabled on this system

I just loaded PowerShell and VI Toolkit on my new laptop and I am getting the following security error "snapshot.ps1 cannot be loaded because the execution of scripts is disabled on

this system." What security permission or policy do i have to modify to correct this problem?

1 Solution

Accepted Solutions
Niket
Enthusiast
Enthusiast
Jump to solution

Hi,

The Set-ExecutionPolicy changes the user preference for the execution policy of the shell. The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

You need to set the executionpolicy to unrestricted using the below cmdlet

set-executionpolicy unrestricted

get-executionpolicy will return the current executionpolicy.

Thanks

Niket

View solution in original post

5 Replies
Niket
Enthusiast
Enthusiast
Jump to solution

Hi,

The Set-ExecutionPolicy changes the user preference for the execution policy of the shell. The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

You need to set the executionpolicy to unrestricted using the below cmdlet

set-executionpolicy unrestricted

get-executionpolicy will return the current executionpolicy.

Thanks

Niket

dwchan
Enthusiast
Enthusiast
Jump to solution

Awesome, that works Smiley Wink thanks

Reply
0 Kudos
aharden
Enthusiast
Enthusiast
Jump to solution

Default ExecutionPolicy is Restricted. Unrestricted is unnecessarily risky. Set-ExecutionPolicy RemoteSigned is more secure and works for VI Toolkit 1.5.

Reply
0 Kudos
zsustar
Contributor
Contributor
Jump to solution

I have to edit the wirte permission in REGEDIT to funtion the command, otherwise it was keeping remind you:

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You're not running the PowerShell session "as an administrator" and then UAC will not allow you to change a HKLM registry entry.

See this Execution Policy and Vista post for the reasoning behind this..


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos