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.


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)

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright ยฉ Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap