How to Run PowerShell Script (.ps1) on Mac

In order to run PowerShell Script on Mac, you will first need to install PowerShell on your macOS.

Article:

How to install PowerShell on Mac (M1/M2/Intel) using Brew


One you PowerShell installed, you can run a .ps1 (PowerShell) script as follows.

pwsh path/of/script/powershell-script-name.ps1

Example:

hello.ps1

Write-Host "Hello from PowerShell on Mac! (macOS)"
% pwsh ~/Desktop/hello.ps1

Hello from PowerShell on Mac! (macOS
Running PowerShell Script on Mac (macOS)

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!