Concept Flow - Why variables store data
Start script
Create variable
Assign value to variable
Use variable in commands
Output variable value
End script
This flow shows how a variable is created, given a value, and then used to store and output data.
$name = "Alice"
Write-Output $name| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Create variable $name and assign 'Alice' | $name | "Alice" | |
| 2 | Output the value of $name | $name | "Alice" | Alice |
| Variable | Start | After Step 1 | After Step 2 |
|---|---|---|---|
| $name | undefined | "Alice" | "Alice" |
Variables store data by holding values assigned to them. Assign a value using $variable = value. Use the variable name to access stored data. Variables must be assigned before use. Output shows the stored value.