PowerShell
Microsoft PowerShell
Object-oriented shell with .NET integration, cross-platform
Overview
PowerShell is a cross-platform task automation solution from Microsoft. Unlike traditional shells that pass text, PowerShell passes .NET objects through pipelines. Originally Windows-only, PowerShell Core (7+) runs on macOS and Linux.
Quick Facts
| Full Name | Microsoft PowerShell |
| Category | Specialized |
| POSIX Compliant | No |
| Config File | $PROFILE (Microsoft.PowerShell_profile.ps1) |
| Default On | Windows |
| First Release | 2006 |
Who Should Use PowerShell?
- Windows administrators - Native Windows management
- DevOps engineers - Azure and cloud automation
- .NET developers - Seamless .NET integration
- Cross-platform automation - Consistent experience across OS
Installation
Install PowerShell on various platforms.
# Install on macOS
brew install powershell/tap/powershell
# Install on Ubuntu
sudo apt-get install -y wget apt-transport-https software-properties-common
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell
# Install on Fedora
sudo dnf install powershell
# Run PowerShell
pwshBasic Usage
PowerShell object-oriented scripting.
# Variables
$name = "World"
Write-Host "Hello, $name!"
# Arrays and hashtables
$fruits = @("apple", "banana", "cherry")
$colors = @{red = "#FF0000"; green = "#00FF00"}
# Object pipeline (not text!)
Get-Process | Where-Object { $_.CPU -gt 10 } | Select-Object Name, CPU
# Conditionals
if ($name -eq "World") {
Write-Host "Match!"
}
# Functions
function Greet {
param([string]$Name)
Write-Host "Hello, $Name!"
}Configuration
PowerShell profile configuration.
# Profile location
$PROFILE # Shows profile path
# Edit profile
notepad $PROFILE # Windows
code $PROFILE # VS Code
# Example profile content
# Set custom prompt
function prompt {
"PS $($PWD.Path)> "
}
# Aliases
Set-Alias -Name ll -Value Get-ChildItem
Set-Alias -Name g -Value git
# Import modules
Import-Module posh-git
Import-Module Terminal-IconsKey Features
Object Pipeline
Pass .NET objects, not text strings
Cmdlet System
Verb-Noun naming convention for discoverability
Cross-Platform
Runs on Windows, macOS, and Linux
Remote Management
Native remoting with Enter-PSSession
FAQ
Should I use PowerShell on Linux?
PowerShell on Linux is useful for cross-platform scripts, Azure automation, and managing heterogeneous environments. For Linux-native tasks, traditional shells may be more appropriate.
What is the difference between Windows PowerShell and PowerShell Core?
Windows PowerShell (5.1) is Windows-only and based on .NET Framework. PowerShell Core (6+, now just "PowerShell" 7+) is cross-platform and based on .NET Core/.NET 5+.
Summary
Key takeaways for PowerShell:
- Object-oriented shell with .NET integration
- Cross-platform (Windows, macOS, Linux)
- Powerful for Windows and Azure administration
- Different paradigm from traditional Unix shells
Official Documentation
For authoritative information, refer to the official documentation: