The PowerShell script is a collection of commands that can be used to change system settings and do other tasks. However, many users don’t know how to run PowerShell script on Windows 10. Don’t worry! MiniTool will walk you through a full guide to do that.

Windows PowerShell is a command-line shell that enables you to run commands in the scripting environment. If you want to run a PowerShell script, you need to create a script file first. PowerShell script is saved in a text file by using the .ps1 extension.

However, you may receive the error message “cannot be loaded because running script is disabled on this system” when double-clicking the .ps1 file. To run PowerShell script successfully, you can keep reading the following context.

How to Create PowerShell Script on Windows 10

First of all, you need to create PowerShell scripts files. It can be created by using the Notepad. Alternatively, you can use ISE (Integrated Scripting Environment) that is a built-in tool in the preinstalled environment. Here’s how:

Method 1. Create a PowerShell Script File with Notepad

Step 1. Type notepad in the search box and click the Notepad on the top result.

open the notepad

Step 2. Now you can write a new script on the context file. For example, copy and paste Write-Host “Congratulations! Your first script executed successfully” into the context file.

type the script in the Notepad

Step 3. Then click on the File menu on the upper left corner and click the Save as button.

click on the Save as button

Step 4. Select a location where t you want to save the file and type a new name for the script file followed by the end of .ps1 such as first_script.ps1. After that, click on the Save button.

type a name for the script and click on the Save button

Method 2. Create a PowerShell Script File with Integrated Scripting Environment

In addition, you can use the Windows built-in tool ISE to create a script file. This method is relatively complex, please read the following part carefully.

Step 1. Type Windows PowerShell ISE in the search box, and then right-click the top result and select Run as administrator option.

run Windows PowerShell ISE as an administrator

Step 2. Press Ctrl + N keys on the keyboard to create a new empty .ps1 file.

Step 3. In the new empty file, type or paste a new script file that you want to run. For example, we write Write-Host “Congratulations! Your first script executed successfully”.

create a new script file

Step 4. Press Ctrl + S keys on the keyboard to save the script file.

Step 5. In the file explorer, select a location that you want to save in and rename it followed by the end of .ps1. After that, click on the Save button.

After you create the script file using Notepad or PowerShell ISE, it should be ready to run. However, it will fail to work by default, because the default PowerShell settings will always prevent any script from executing.

How to Find Windows 10 Product Key? Here Are 4 Methods
How to Find Windows 10 Product Key? Here Are 4 Methods

Product key is important to activate your Windows. A great many users are looking for the way to find Windows 10 product key. This post can help you.

Read More

How to Run PowerShell Script on Windows 10

Now, you may wonder how to run a PowerShell script on Windows 10. To run PowerShell scripts on Windows 10, you need to change the execution policy. Here’s how to do that:

Step 1. Type PowerShell in the search box, and then right-click the top result and select Run as administrator option.

run Windows PowerShell as an administrator

Step 2. Type the Set-ExecutionPolicy RemoteSigned command in the window and press Enter.

Step 3. Type A and hit Enter.

Tip: RemoteSigned is an execution policy that enables the script to run on the computer. However, if you create the script on another computer, it won’t run unless the script contains a signature of a trusted publisher.

change the execution policy

Step 4. Then type & “C:PATHTOSCRIPTfirst_script.ps1 command and hit Enter to run the PowerShell scripts.

Note: In the command, replace the PATHTOSCRIPT with the actual location where you saved the script.

After you complete all the above steps, you should run PowerShell scripts smoothly and see the outputs.

  • linkedin
  • reddit