0
0
PowerShellscripting~10 mins

String interpolation (double quotes) in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the variable inside double quotes using string interpolation.

PowerShell
Write-Output "Hello, [1]!"
Drag options to blanks, or click blank then click option'
A$name
Bname
C'name'
D`name
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the $ sign before the variable name.
Using single quotes which do not expand variables.
2fill in blank
medium

Complete the code to include the variable $age inside the string using double quotes.

PowerShell
Write-Output "I am [1] years old."
Drag options to blanks, or click blank then click option'
A'$age'
Bage
C`age
D$age
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without $ sign.
Using single quotes which do not expand variables.
3fill in blank
hard

Complete the code to include the variable $city inside the string using double quotes.

PowerShell
Write-Output "Welcome to [1]!"
Drag options to blanks, or click blank then click option'
A`city
Bcity
C$city
D'$city'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which do not expand variables.
Forgetting the $ sign before the variable.
4fill in blank
hard

Fill both blanks to correctly display the full name using variables $first and $last inside a string.

PowerShell
Write-Output "Full name: [1] [2]"
Drag options to blanks, or click blank then click option'
A$first
B$last
Cfirst
Dlast
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without $ sign.
Using single quotes instead of double quotes.
5fill in blank
hard

Fill all three blanks to create a greeting with variables $greeting, $name, and $punctuation inside double quotes.

PowerShell
Write-Output "[1], [2][3]"
Drag options to blanks, or click blank then click option'
A$greeting
B$name
C$punctuation
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without $ sign.
Using single quotes instead of double quotes.