0
0
PowerShellscripting~10 mins

Variable creation with $ in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Variable creation with $ in PowerShell
📖 Scenario: You are writing a simple PowerShell script to store and display information about a fruit.
🎯 Goal: Learn how to create and use variables in PowerShell using the $ symbol.
📋 What You'll Learn
Create a variable with the exact name $fruit
Assign the exact value Apple to $fruit
Create a variable with the exact name $quantity
Assign the exact value 10 to $quantity
Use a variable $message to combine $fruit and $quantity in a string
Print the $message variable
💡 Why This Matters
🌍 Real World
Variables are used in scripts to store data like names, counts, or settings. This helps automate tasks by reusing values easily.
💼 Career
Knowing how to create and use variables is essential for writing PowerShell scripts in IT jobs, system administration, and automation.
Progress0 / 4 steps
1
Create a variable called $fruit
Create a variable called $fruit and assign it the value Apple.
PowerShell
Need a hint?

Use the $ symbol before the variable name and assign the string value with single quotes.

2
Create a variable called $quantity
Create a variable called $quantity and assign it the value 10.
PowerShell
Need a hint?

Remember to use $ before the variable name and assign the number without quotes.

3
Combine variables into $message
Create a variable called $message that combines $quantity and $fruit into the string: 10 Apples. Use double quotes and variable expansion.
PowerShell
Need a hint?

Use double quotes and ${fruit}s to add the 's' after the fruit name.

4
Print the $message variable
Print the value of the variable $message using Write-Output.
PowerShell
Need a hint?

Use Write-Output $message to display the message.