wesupport

Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Powershell to enable script execution – How we do it

by | Feb 12, 2021

Stuck with PowerShell to enable script execution? We can help you.

Usually, users can’t run any scripts by just double-clicking a file. It is a troublesome process.

As a part of our Server Management Services, we assist our customers with script policy queries.

Today, let’s discuss how our Support Engineers do it easily for our customers.

 

A quick look at 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.

Our Support Engineers 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-ExecutionPolicy unrestricted” command.
  3. Next, it asked for confirmationDo you want to change the execution policy. By default, it is set to Nand 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 the error?- We’re available 24/7.]

 

Conclusion

In short, we changed PowerShell to enable script execution by running some commands. Today, we discussed how our Support Engineers resolve the script error for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

3 Comments

  1. Jeff Green

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

    This gives a syntax error, where “Set-ExecutionPolicy unrestricted” does not.

    Reply
    • Syam S

      Please contact our support team

      Reply
  2. Veronique Kisch

    This is the perfect web site for anyone who would like to understand this topic. You know a whole lot its almost hard to argue with you (not that I actually would want to…HaHa). You certainly put a fresh spin on a subject which has been discussed for years. Excellent stuff, just wonderful!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags