| name | powershell |
| description | PowerShell 5.1 and 7+ syntax for live terminal execution and .ps1 script authoring: pipelines, redirection, here-strings, backtick continuation, and copy-paste-safe blocks. Use when running PowerShell commands in a session or when writing or editing .ps1 scripts on Windows or cross-platform PS 7+. |
PowerShell
PowerShell syntax for live session commands and .ps1 script files. Activate via terminal/SKILL.md after context detection.
Version awareness
| Edition | Version | Notes |
|---|
| Windows PowerShell | 5.1 | $PSVersionTable.PSEdition = Desktop; Windows only |
| PowerShell | 7+ | $PSVersionTable.PSEdition = Core; cross-platform |
Probe:
$PSVersionTable.PSVersion
$PSVersionTable.PSEdition
When docs say "PowerShell" without version, write 7+-compatible syntax when possible; note 5.1 gaps.
Copy-paste rules (live)
- Comments:
# only — not REM
- Line continuation: backtick
` as last character on line
- No prose inside fenced blocks
- Prefer single-quoted strings when no expansion needed
Multiline example:
Get-ChildItem -Path . `
-Filter *.md `
| Select-Object Name
Pipelines and redirection
Get-Process | Where-Object CPU -gt 100
command 2>&1 | Out-File log.txt
command *> log.txt
Operators: |, ;, &&, || (7+), -and, -or.
Variables and paths
$env:PATH
$env:USERPROFILE
Join-Path $PSScriptRoot 'config.json'
Inspect commands:
Get-Command node
Get-Command git -ErrorAction SilentlyContinue
Here-strings (scripts and paste)
@'
Line one
Line two
'@
@"
Hello $env:USERNAME
"@
Use @' ... '@ when content must be literal (no expansion).
Admin and elevation
Prefer non-admin. See admin-elevation.md.
Elevated one-liner (offer explicitly):
Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile -Command "yourcommand"'
Script conventions
#Requires -Version 7.0
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$Target
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
Copy-paste vs documentation
- Live: one fence, detected PS version when known
- Docs: separate Windows PowerShell 5.1 and PowerShell 7+ sections when syntax differs
Additional resources