Recall & Review
beginner
What is a return value in PowerShell?
A return value is the output a function sends back after it finishes running. It can be used later in the script.
Click to reveal answer
beginner
How do you return a value from a PowerShell function?
You use the
return keyword followed by the value you want to send back.Click to reveal answer
intermediate
What happens if you don't use
return in a PowerShell function?PowerShell returns any output generated by the function automatically, even without the
return keyword.Click to reveal answer
intermediate
Can a PowerShell function return multiple values?
Yes, a function can output multiple values by writing them to the output stream. These values can be collected as an array.
Click to reveal answer
advanced
What is the difference between
return and outputting values directly in PowerShell?return exits the function immediately and sends back the value. Outputting values without return sends them but the function continues running.Click to reveal answer
What keyword is used to explicitly send a value back from a PowerShell function?
✗ Incorrect
The
return keyword sends a value back from a function.If a PowerShell function outputs a value but does not use
return, what happens?✗ Incorrect
PowerShell returns any output from the function even without
return.How can a PowerShell function return multiple values?
✗ Incorrect
Outputting multiple values sends them all to the output stream, which can be collected as an array.
What does the
return keyword do besides sending a value back?✗ Incorrect
return exits the function immediately after sending the value.Which of these is a correct way to return the number 5 from a PowerShell function?
✗ Incorrect
The correct syntax to return a value is
return 5.Explain how return values work in PowerShell functions and how they can be used.
Think about how functions send data back to the caller.
You got /4 concepts.
Describe the difference between using
return and just outputting values in a PowerShell function.Consider what happens after sending the value.
You got /3 concepts.