.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.

How to open 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

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 file signature (magic bytes)

Programs recognise a .ps1 file by the bytes at the start of the file, not by its name. These are the signatures for PS1.

Hex signatureOffsetNote
(no fixed signature)0plain text; no fixed signature

See the full magic-numbers reference for every format.

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: