On Windows 10, PowerShell is a command-line tool that allows you to run commands and scripts to change system settings and automate tasks. It's similar to Command Prompt, but PowerShell is a more capable command-line interface (CLI) that provides an extensive set of tools and offers more flexibility and control (especially for scripting).

A script is just a collection of commands saved into a text file (using the .ps1 extension) that PowerShell can understand and execute in sequence to perform one or multiple actions. The only caveat is that unlike Command Prompt, the default security protocol prevents all scripts from running.

This means that when double-clicking a .ps1 file on Windows 10 nothing will happen, and if you try to execute the script within PowerShell, you'll get the "cannot be loaded because running scripts is disabled on this system" error message. However, it's not impossible to run scripts on your device. You just need to enable the correct execution policy.

In this Windows 10 guide, we walk you through the steps to successfully run your first script file on PowerShell.

How to create a PowerShell script file on Windows 10

On Windows 10, you can create PowerShell script files using virtually any text editor or the built-in Integrated Scripting Environment (ISE) console.

Creating a script using Notepad

To create a PowerShell script using Notepad on Windows 10, use these steps:

  1. Open Start.
  2. Search for Notepad, and click the top result to open the app.
  3. Write a new or paste your script — for example:

    Write-Host "Congratulations! Your first script executed successfully"

    The above script will output the phrase "Congratulations! Your first script executed successfully" on the screen.

  4. Click the File menu.
  5. Click the Save button.
  6. Type a name for the script — for example, first_script.ps1.

  7. Click the Save button.

Creating a script using Integrated Scripting Environment (ISE)

Alternatively, you can use the built-in PowerShell ISE console to code your scripts on Windows 10.

The Integrated Scripting Environment is a complex tool, but you can get started using these steps:

  1. Open Start.
  2. Search for Windows PowerShell ISE, right-click the top result, and select the Run as administrator option.
  3. The environment will launch with an empty .ps1 file, where you can write a new or paste the script you want to run — for example:

    Write-Host "Congratulations! Your first script executed successfully"

  4. Click the File menu.
  5. Click the Save option.
  6. Type a name for the script. For example, first_script.ps1.

  7. Click the Save button.

Once you complete the steps using Notepad or PowerShell ISE, the script is ready to run, but it will fail by default. This is because the default PowerShell settings are always set to block the execution of any script.

How to run a PowerShell script file on Windows 10

If you want to run a script file on PowerShell, you have to change the execution policy on Windows 10.

To change the execution policy to run PowerShell scripts, use these steps:

  1. Open Start.
  2. Search for PowerShell, right-click the top-result and click the Run as administrator option.
  3. Type the following command to allow scripts to run and press Enter:

    Set-ExecutionPolicy RemoteSigned

  4. Type A and press Enter.

  5. Type the following command to run the script and press Enter:

    & "C:\PATH\TO\SCRIPT\first_script.ps1"

    In the above command, make sure to change "PATH\TO\SCRIPT" to the location of your script.

After you complete the steps, the script will run and if it was crafted correctly, you should see its output without issues.

On Windows 10, PowerShell includes four execution policies, including:

  • Restricted — Stops any script from running.
  • RemoteSigned — Runs scripts created on the device. However, scripts created on another computer won't run unless they include a signature of a trusted publisher.
  • AllSigned — All the scripts will run as long as they've been signed by a trusted publisher.
  • Unrestricted — Runs any script without any restrictions.

In the above steps, we use the command to allow local scripts to run on Windows 10. However, if you're not planning to execute scripts regularly, you can restore the default settings using the same instructions, but on step No. 4, make sure to use the Set-ExecutionPolicy Restricted command.

More Windows 10 resources

For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:

Mauro recommends all these affordable accessories

Hi, I'm Mauro Huculak, Windows Central's help and how-to guru. I wrote the post you're reading now, and I know the Windows OS inside and out. But I'm also a bit of a hardware geek. These are some of the affordable gadgets on my desk today.

Logitech MX Master Wireless Mouse ($72 at Amazon)

I know mice, and this is the one I use every day. The MX Master is a wireless high-precision mouse that's very comfortable to use and has many great features, including the ability to connect with multiple devices, an infinite scroll wheel, back and forward buttons, all of which you can customize.

Ktrio Extended Gaming Mouse Pad ($12 at Amazon)

If you spend a lot of time typing, your palms and mouse will leave tracks on your desk. My solution was to start using gaming mouse pads, which are big enough for you to use the keyboard and the mouse comfortably. This is the one I use and recommend.

Supernight LED light strip ($20 at Amazon)

You could just use a regular light bulb in your office, but if you want to add some ambient lighting with different colors, an RGB LED strip is the way to go. This one is Mauro-approved.

This post may contain affiliate links. See our disclosure policy for more details.