Bird
0
0

Given the following code:

medium📝 Command Output Q13 of 15
PowerShell - Working with Objects
Given the following code:
$a = 1, 2, 3, 4
$b = 3, 4, 5, 6
Compare-Object -ReferenceObject $a -DifferenceObject $b

What is the output?
A3 and 4 with SideIndicator '<=', 5 and 6 with SideIndicator '=>'
B1, 2, 3, 4, 5, 6 all with SideIndicator '=='
C1 and 2 with SideIndicator '<=', 5 and 6 with SideIndicator '=>'
DNo output because all items match
Step-by-Step Solution
Solution:
  1. Step 1: Identify unique items in each array

    $a has 1, 2 unique; $b has 5, 6 unique; 3 and 4 are common.
  2. Step 2: Understand SideIndicator meaning

    Items only in $a show '<='; items only in $b show '=>'.
  3. Final Answer:

    1 and 2 with SideIndicator '<=', 5 and 6 with SideIndicator '=>' -> Option C
  4. Quick Check:

    Unique items show with correct SideIndicator [OK]
Quick Trick: SideIndicator '<=' means only in ReferenceObject [OK]
Common Mistakes:
  • Including common items in output
  • Mixing up SideIndicator symbols
  • Assuming no output if some items match

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes