0
0
PowerShellscripting~10 mins

Boolean values 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 assign the Boolean value True to the variable.

PowerShell
$isActive = [1]
Drag options to blanks, or click blank then click option'
ATrue
B$true
C1
Dyes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'True' without the dollar sign causes an error.
Using 1 or 'yes' are not Boolean literals in PowerShell.
2fill in blank
medium

Complete the code to check if the variable $flag is False.

PowerShell
if ($flag -eq [1]) { Write-Output 'Flag is false' }
Drag options to blanks, or click blank then click option'
A0
BFalse
C$false
Dno
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'False' without the dollar sign causes errors.
Using 0 or 'no' are not Boolean literals in PowerShell.
3fill in blank
hard

Fix the error in the code to correctly assign a Boolean False value.

PowerShell
$isComplete = [1]
Drag options to blanks, or click blank then click option'
A$false
B$False
Cfalse
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'False' or 'false' without the dollar sign.
Using uppercase $False causes errors in some contexts.
4fill in blank
hard

Fill both blanks to create a Boolean expression that checks if $value is True and $status is False.

PowerShell
if ($value -eq [1] -and $status -eq [2]) { Write-Output 'Condition met' }
Drag options to blanks, or click blank then click option'
A$true
B$false
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'True' or 'False' without the dollar sign.
Mixing uppercase and lowercase letters.
5fill in blank
hard

Fill all three blanks to create a Boolean expression that checks if $a is True, $b is False, and $c is True.

PowerShell
if ($a -eq [1] -and $b -eq [2] -and $c -eq [3]) { Write-Output 'Check passed' }
Drag options to blanks, or click blank then click option'
A$true
B$false
CFalse
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'True' or 'False' without the dollar sign.
Confusing the order of logical operators.