Share
Explore

Here are the detailed steps to install and use PowerShell on macOS



Prerequisites: - macOS 10.13 or later - Homebrew package manager
Installation:
1. Install Homebrew if you don't already have it:
``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ```
2. Install PowerShell using Homebrew:
``` brew install --cask powershell ```
3. Verify the installation:
``` pwsh ```
This will launch the PowerShell prompt if installed correctly.
Upgrading PowerShell:
1. Update Homebrew's formulae:
``` brew update ```
2. Upgrade PowerShell:
``` brew upgrade powershell --cask ```
3. Relaunch PowerShell for changes to take effect.
Usage:
- Launch PowerShell by typing `pwsh` in Terminal.
- Run PowerShell commands and scripts. For example:
``` Get-Process Write-Output "Hello World" ./myscript.ps1 ```
- Access help and documentation:
``` Get-Help Get-Command ```
- Install modules from the PowerShell Gallery:
``` Install-Module Azure Import-Module Azure ```
- Access built-in cmdlets like Get-Process, Set-Location, Get-ChildItem etc.
- Use PowerShell providers like Registry, Certificate, FileSystem etc.
- Leverage piping, objects and .NET access in PowerShell scripts.
So in summary, PowerShell on macOS provides access to the same powerful automation and scripting capabilities as on Windows, with a few easy installation steps.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.