Powershell to enable script execution

Are you trying to use PowerShell to enable script execution?

This guide will help you.

Basically, Windows users can't run any scripts by just double-clicking a file. It is a troublesome process.

By default, PowerShell's execution policy is set to Restricted; this means that scripts will not run. You can verify the execution policy setting by using the Get-ExecutionPolicy PowerShell command. 

You can change the PowerShell script execution behavior using "Set-ExecutionPolicy".

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform PowerShell related queries.

In this context, we shall look into how to enable script execution via Powershell.

More information about PowerShell ?

Windows PowerShell is an object-oriented automation engine and scripting language built on .NET.

In addition, it helps system administrators and power-users to rapidly automate tasks.

.ps1 file is the extension for the PowerShell script. By default, we can’t run a script by just double-clicking a file.

This usually restricts the accidental harm from happening.

During the execution of scripts via PowerShell, it seems like there are some policies that restrict the script execution from happening.

Execution Policies during PowerShell script execution

Let us now discuss some major policies. We get one of these outputs during script execution.

Restricted: This message will pop up when we first run any script. This is because Scripts are not allowable here

AllSigned: Here, with this setting, the script will ask for confirmation that we need to run before its execution.

Unrestricted: Here, there are no restrictions present. We can run any scripts that we want.

RemoteSigned: In this case, we can run the scripts that are only signed by a trusted developer.

How we enabled Script Execution in Powershell?

Recently, one of our customers approached us with the following error message:

File C:\Common\Scripts\hello.ps1 cannot load because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

Then, we checked the error and in order to fix it, we went ahead with the below steps:

Initially, we open the PowerShell command prompt with the 'Administrator' privilege.

Then we enter the following commands:

1. Firstly we execute Get-ExecutionPolicy with result as “Restricted”.

2. Then, to make it unrestricted we execute the “set-execution policy unrestricted” command.

3. Next, it asked for confirmation "Do you want to change the execution policy". By default, it is set to “N” and we need to change it to “Y”.

4. Finally, we execute the Get-ExecutionPolicy command so as to check the changed policies. It results in unrestricted privilege.

After doing all these we create a file in notepad and save it with an extension.ps1. For example, myscript.ps1

In the PowerShell, we call the script using the command & “X:\myscript.ps1

Thus, we enabled the script execution in PowerShell.

[Couldn't fix this Windows PowerShell error? -  We're available 24/7.  ]


This article will guide you on how to fix #Windows script error via PowerShell. Basically, we used #PowerShell to enable script #execution by running some #commands.

PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and scripting language. Unlike most shells, which accept and return text, PowerShell is built on top of the . #NET Common Language Runtime (CLR), and accepts and returns . NET objects.

To enable script execution in PowerShell:

i. Open Start.

ii. Search for PowerShell, right-click the top-result and click the Run as administrator option.

iii. Type the following command to allow scripts to run and press Enter: Set-ExecutionPolicy RemoteSigned.

iv. Type A and press Enter (if applicable).

For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com