If you want to run a Powershell script (.ps1) on your device, you can do that in the following ways depending upon the OS that you are on.
On Mac (macOS)
- Open Terminal (type 'Terminal' in Spotlight search and press enter)
- Now Type:
pwsh ./path/to/your/powershell/script.ps1
- The script will get executed.

On Windows
- Open PowerShell (type 'PowerShell' in the Start menu and press Enter)
- Now, navigate to the directory containing your PowerShell script using the `cd` (Change Directory) command:
cd C:\path\to\your\script\directory
- Execute your PowerShell script using the `.\` prefix to specify the current directory:
.\powershell-script.ps1
- The script will get executed.
On Linux (Ubuntu, Debian, CentOS, etc.)
- Open a terminal (You can find the terminal application in your applications menu)
- Navigate to the directory containing your PowerShell script using the cd (Change Directory) command:
cd /path/to/your/script/directory
- Make sure you have PowerShell installed on your Linux distribution. If not, follow the official Microsoft documentation for installation: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux
- Execute your PowerShell script using the pwsh command:
pwsh ./powershell-script.ps1
- The script will get executed.
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Powershell,
- PowerShell: How to Check if a Module is Already Installed
- PowerShell: How to Write Output to a File
- PowerShell: Steps to Connect to connect to Exchange Online
- PowerShell Fix: Get-Help cannot find the Help files for this cmdlet on this computer
- PowerShell Traditional For Loop Example
- How to Run PowerShell Script as Administrator (Elevate)
- Update Powershell Using Command Line
- How to delete a file using PowerShell [Windows/macOS]
- PowerShell: Grep Command Alternative - Select-String
- PowerShell Concatenate String Examples
- How to add Sleep to PowerShell Script
- Connect Azure AD (Active Directory) for PowerShell
- How to Open PowerShell on Mac?
- List of PowerShell Function Commands for Mac
- How to Connect to Azure AD Account using PowerShell on Mac
- Download Google Chrome setup exe file using PowerShell
- Set Environment Variable in PowerShell for Mac
- How to switch to Powershell on Mac Terminal
- How to add sleep in Powershell Script
- PowerShell on Mac: The term get-service is not recognized as a name of a cmdlet, function, script file, or executable program
- How to Identify installed PowerShell version
- How to check PowerShell version
- How to install PowerShell on Mac using Brew
- PowerShell Switch Statement with Examples
- PowerShell ISE Alternative for Mac
More Posts:
- Fix: Minecraft EXCEPTION_ACCESS_VIOLATION Fatal Error Java Runtime - Java
- How to open terminal on Mac to run commands - MacOS
- How to pass authorization header using cURL - cURL
- MySQL ERROR 1064 (42000): You have an error in your SQL syntax [fix] - MySQL
- How to add Colors to VIM (syntax highlighting) - vi
- Best way to calculate elapsed time in Java using Java 8 Duration & Instant Class with Nanoseconds precision - Java
- Annual Surveys that Software Developers Should Look for! - News
- Fix - ssh-copy-id no identities found error - Linux