Recall & Review
beginner Click to reveal answer
What are Boolean values in PowerShell?
Boolean values represent two states: True or False. They are used to control logic and decisions in scripts.
beginner Click to reveal answer
How do you assign a Boolean value to a variable in PowerShell?
You assign it like this:
$isReady = $true or $isDone = $false. Use $true and $false keywords.beginner Click to reveal answer
What will this PowerShell code output?
$a = $true
if ($a) { 'Yes' } else { 'No' }
It will output Yes because the variable
$a is $true, so the if condition passes.beginner Click to reveal answer
Can Boolean values be used directly in conditions in PowerShell? Explain.
Yes, Boolean values like
$true or $false can be used directly in if or while conditions to control flow.intermediate Click to reveal answer
What is the difference between
$true and 1 in PowerShell?$true is a Boolean value representing true. 1 is a number. PowerShell treats $true as 1 in numeric context but they are different types.Which keyword represents a true Boolean value in PowerShell?
✗ Incorrect
PowerShell uses the keyword
$true (case-insensitive) to represent the Boolean true value.What will this code output?
$flag = $false
if (-not $flag) { 'No' } else { 'Yes' }
✗ Incorrect
The
-not operator negates $false to $true, so the if block runs and outputs 'No'.Which of these is NOT a valid Boolean value in PowerShell?
✗ Incorrect
True without the $ is not a valid Boolean value in PowerShell.How do you check if a variable $x is true in PowerShell?
✗ Incorrect
Both
if ($x -eq $true) and if ($x) correctly check if $x is true.What type of value is $true in PowerShell?
✗ Incorrect
$true is a Boolean type representing the logical true value.Explain how Boolean values control the flow of a PowerShell script.
Think about how scripts decide what to do next.
You got /5 concepts.
Describe how to assign and use Boolean variables in PowerShell with an example.
Show a simple script snippet.
You got /4 concepts.
