Trying to make the Powershell script executable in Windows? We can help you.

PowerShell scripts are easy to use but there are a couple of things to be aware of, especially when it is the first time you use such scripts.

At Bobcares, we often receive requests regarding PowerShell as a part of our Server Management Services.

Today, let’s discuss how our Support Engineers execute a script in Powershell for our customers.

How to make PowerShell script Executable

PowerShell can be used instead of traditional windows batch files. The batch files don’t have access to the full range of.NET tool and it makes PowerShell often more powerful. PowerShell is a command-line interface offers more flexibility and control for scripting.


Creating a PowerShell script

We follow the below steps to create a PowerShell script in notepad.

1. We open the Notepad.

2. Then we write our sample script on the text file.

Write-Host "Hello, Welcome to Bobcares"

The above script shows the outputs as  “Hello, Welcome to Bobcares”

3. After that, we click the File menu > Select the Save as option.

4. We save the file as my_first_script.ps1 in ps1 extension.

5. Then we click the save button.


How we open the PowerShell

It is quite easy to open the Powershell command windows. There are some methods available to open the Powershell.

  • One method is to right-click on the Start Menu icon and choose Windows PowerShell.
  • Second is just type PowerShell directly after opening the Start Menu or within the Search box.

Before opening the PowerShell we change the execution policy. The default PowerShell settings are always set to block the execution of any script and it shows fail to run the script in the PowerShell.

How to run a script in powershell

We change the execution policy by right-clicking the PowerShell and click the Run as administrator option.


Steps to Execute the PowerShell script

We follow the below steps to execute the script in the Powershell after changing the execution policy.

1. We type the following command to allow scripts to run.

Set-ExecutionPolicy RemoteSigned

RemoteSigned is an execution policy that Runs scripts created on the device. The PowerShell includes four execution policies.

  1. RemoteSigned – It only runs the scripts created on the device and the scripts created on another computer are not run by the RemoteSigned unless they include a signature of a trusted publisher.
  2. Unrestricted – It runs any script without any restrictions.
  3. AllSigned – The script is run as long as if it is signed by a trusted publisher.
  4. Restricted – It stops any script from running

2. After that, we press Enter.

3. We type the following command to EXECUTE the script and press Enter.


In the above command, we write the full path to the script. After completing the steps, the script runs successfully and output displays without any issues.


[Need help to run a script in PowerShell? – We’ll help you]



Today, we’ve discussed how to create a sample PowerShell script. Also, we have discussed how our Support Engineers execute a script in PowerShell.


Source link


Write A Comment