Bird
0
0

Which of the following is the correct way to assign a Boolean value in PowerShell?

easy📝 Syntax Q12 of 15
PowerShell - Variables and Data Types
Which of the following is the correct way to assign a Boolean value in PowerShell?
A$flag = $true
B$flag = True
C$flag := $true
Dflag = $true
Step-by-Step Solution
Solution:
  1. Step 1: Check assignment syntax in PowerShell

    PowerShell uses = to assign values to variables, and variables start with $.
  2. Step 2: Identify correct Boolean value and syntax

    The Boolean value must be $true with $ sign, and assignment uses =.
  3. Final Answer:

    $flag = $true -> Option A
  4. Quick Check:

    Assign Boolean with $true and = [OK]
Quick Trick: Use $true with = for Boolean assignment [OK]
Common Mistakes:
  • Missing $ on Boolean value
  • Using := instead of =
  • Missing $ on variable name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes