How to fix PowerCLI and/or PowerShell running scripts is disabled

Posted by

I know this one should be real basic but sometimes we forget the basics.  Have you ever stood up a new environment, installed PowerShell, PowerCLI, imported your favorite scripts and when to execute and got a permission error.  Were you rusty on how to change permissions to give yourself the capability to run scripts?  Here is a quick article on how to change the ExecutionPolicy in PowerShell.

Error:
File C:\——\——\ExampleScript.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : UnauthorizedAccess

Machine generated alternative text:
bgcansø. rnnninq scripts is disabled on this system. For more information, see at https:/go.microsoft.cexn/fB1ink/?Link1D=135170.L

How to fix:
Run the following command:
Get-ExecutionPolicy

The result should say:
Restricted

Use the following command to change it to unrestricted:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Other options:
AllSigned – Only scripts signed by a trusted publisher can be run.
RemoteSigned – Downloaded scripts must be signed by a trusted publisher.

Summary:
Not much to say besides I hope y’all found this article useful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s