.ps1

What is a .ps1 file?

PowerShell Script · Code and data · Microsoft · 2006

A PS1 file is a PowerShell script, plain-text commands for Windows PowerShell that can automate almost anything on a system. It is powerful, and Windows restricts running scripts by default, so read one before you let it run.

Category
Code and data
Type
Plain text
Is a .ps1 file safe to open? Caution. A PowerShell script can change system settings, install software or download more code. Windows blocks casual double-click running as a safeguard; read a .ps1 first and only run scripts you trust.

What is a .ps1 file used for?

PowerShell is Windows' modern automation shell, and a .ps1 is a script written in it. It can manage files, services, the registry, networking and much more.

That power is why Windows ships with an execution policy that blocks casually double-clicking a .ps1 to run it, a deliberate safeguard against malicious scripts.

It is plain text, so open it in VS Code or Notepad to read it. To run a trusted one, right-click and choose Run with PowerShell, or adjust the execution policy in a PowerShell window.

Because a script can change system settings or download and run more code, only run .ps1 files from sources you trust.

What opens a .ps1 file?

The .ps1 format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.

Windows

  • VS Code or Notepad (to read/edit)
  • Right-click, Run with PowerShell (to run, subject to execution policy)

macOS

  • Text editor (to read)
  • PowerShell 7 (if installed)

Linux

  • Text editor (to read)
  • PowerShell 7 (if installed)

Web

  • Not applicable

Open a .ps1 file step by step

  1. Confirm the file really is a .ps1. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with VS Code or Notepad (to read/edit) or Right-click, Run with PowerShell (to run, subject to execution policy).
  3. On Mac, use Text editor (to read) or PowerShell 7 (if installed).
  4. On Linux, try Text editor (to read) or PowerShell 7 (if installed).
  5. Still stuck? Convert the .ps1 to Not convertible, which opens more widely.

Why can't I open my .ps1 file?

Almost always because no installed app understands PS1. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .ps1 at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

How to convert a .ps1 file

You can convert a .ps1 file to Not convertible using a conversion tool or the export menu of an app that opens it.

PS1 has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

Frequently asked questions

What is a .ps1 file?

A PS1 file is a PowerShell script, plain-text commands for Windows PowerShell that can automate almost anything on a system. It is powerful, and Windows restricts running scripts by default, so read one before you let it run.

How do I run a PS1 file?

Right-click it and choose Run with PowerShell, or open a PowerShell window and run it by path. If it is blocked, that is the execution policy, which you can adjust for trusted scripts.

Why won't my .ps1 run?

By default Windows PowerShell refuses to run scripts as a security measure (the execution policy). For a script you trust, you can allow it, but do not loosen that setting for files you cannot vet.

Related formats

Sources

Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.