PowerShell Variables
| COMMAND | DESCRIPTION |
|---|---|
New-Variable var1 |
Create a new variable var1 without defining its value |
Get-Variable my* |
Lists all variables in use beginning with “my*” |
Remove-Variable bad_variable |
Delete the variable called “bad_variable” |
$var = "string" |
Assign the value "string" to a variable $var |
$a,$b = 0 |
Assign the value 0 to the variables $a, $b |
$a,$b,$c = 'a','b','c' |
Assign the characters 'a', 'b', 'c' to respectively-named variables |
$a,$b = $b,$a |
Swap the values of the variables $a and $b |
$var = [int]5 |
Force the variable $var to be strongly typed and only admit integer values |
Comments





