PowerShell: Variable
Variable name starts with a dollar sign $
π‘ TIP: Variable names are case-insensitive.
Variable name can contain space or unicode.
Use {} to quote them, like this:
${odd var name}
Create Variable
$x = 3
Variable can store output of a command
$x = dir
Clear Variable
Set it to $null or use Clear-Variable
$x = $null
Clear-Variable $x
Delete Variable
Remove-Item -Path Variable:\varName
Remove-Item -Path variable:\x
List Variables
dir variable:
here's part of the output:
PowerShell, variable and assignment
Sigils war, special chars in variable names as syntactic type system
- Variable Naming. English Words Considered Harmful
- The Sigil War, Syntactic Indicator for Types of Function and Variable (2016)
- Function Parameter names start with phi Ο, variable names start with xi ΞΎ (2014)
- Emacs Lisp Coding Style. DOLLAR SIGN $ and AT SIGN @ in Variable Names
- Jargon: Predicate in Programing Languages (2014)
- Syntactic Meaning of Variable (2018)
- Perl: Variable Name Prefix (aka Sigil)
- Ruby: Variable Name Conventions
- PowerShell: Variable
- Clojure: Variable Name Conventions (sigil. macro magic characters.)