Getting Started
First experience with PowerShell's basic commands and help system:
- Discover commands and help:
Get-Command: Search for available commands, functions, scripts, aliasesGet-Help <Cmdlet>: View command usage and examples; -Online opens web page; -Full shows complete help
- View system information:
Get-Process, Get-Service, Get-EventLog / Get-WinEventGet-ChildItem (aliases: ls, dir): List directoryGet-Item / Set-Item: Read/write files/registry/environment variables and other general "provider" resources
- Pipeline and filtering:
Where-Object(alias: ?) filters objectsSelect-Object(alias: select) projects propertiesSort-Object(alias: sort) sorts
Example: List the top 5 processes by memory usage, showing only name and working set, sorted by memory in descending order.
powershell
Get-Process |
Sort-Object -Property WorkingSet -Descending |
Select-Object -First 5 -Property Name, Id, @{n='MemoryMB';e={[math]::Round($_.WorkingSet/1MB,2)}}Running scripts:
- Use
.\script.ps1to execute scripts in the current directory - May need to set execution policy:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Editor recommendations:
- VS Code + PowerShell extension: Syntax highlighting, IntelliSense, debugging, code snippets, and refactoring support