Recall & Review
beginner
What does the PowerShell cmdlet <code>Compare-Object</code> do?Compare-Object compares two sets of objects and shows the differences between them.
It helps find what is unique to each set or what is missing.
Click to reveal answer
beginner
What does the
SideIndicator property show in Compare-Object output?SideIndicator tells which input the difference belongs to:
<=means the object is only in the first set.=>means the object is only in the second set.
Click to reveal answer
beginner
How do you compare two text files line by line using
Compare-Object?Use Get-Content to read each file, then compare:
Compare-Object (Get-Content file1.txt) (Get-Content file2.txt)
Click to reveal answer
beginner
What parameter do you use with
Compare-Object to show matching lines?Use -IncludeEqual to show lines that are the same in both sets.
Click to reveal answer
intermediate
Can
Compare-Object compare objects other than strings? Give an example.Yes, it can compare any objects, like numbers or custom objects.
Example:
$a = 1,2,3; $b = 2,3,4; Compare-Object $a $b
Click to reveal answer
What does the
SideIndicator value '<=' mean in Compare-Object output?✗ Incorrect
<= means the object exists only in the first input set.
Which cmdlet reads file content line by line for comparison?
✗ Incorrect
Get-Content reads file content line by line, useful before comparing.
How do you show matching lines in
Compare-Object output?✗ Incorrect
The -IncludeEqual parameter shows lines that are the same in both inputs.
Can
Compare-Object compare arrays of numbers?✗ Incorrect
Compare-Object can compare any objects, including numbers in arrays.
What is the default behavior of
Compare-Object when comparing two sets?✗ Incorrect
By default, it shows only differences unless -IncludeEqual is used.
Explain how to use
Compare-Object to find differences between two text files.Think about reading files and comparing line by line.
You got /4 concepts.
Describe what the
SideIndicator symbols mean in the output of Compare-Object.Focus on which side the difference belongs to.
You got /2 concepts.