Complete the code to compare two arrays and show differences.
$array1 = @(1, 2, 3) $array2 = @(2, 3, 4) Compare-Object $array1 [1] $array2
The -DifferenceObject parameter specifies the second set to compare against the first.
Complete the code to show only differences without side indicators.
Compare-Object -ReferenceObject $list1 -DifferenceObject $list2 [1]The -NoSideIndicator switch hides the side indicator, showing only the differing values.
Fix the error in the code to compare two files and show differences.
$file1 = Get-Content file1.txt
$file2 = Get-Content file2.txt
Compare-Object $file1 [1] $file2The second file content must be passed with -DifferenceObject to compare properly.
Fill both blanks to compare two lists and show only items unique to the first list.
Compare-Object -ReferenceObject $listA -DifferenceObject $listB [1] [2]
-PassThru outputs the differing objects themselves, and -SideIndicator '<=' filters to show only items unique to the first list.
Fill all three blanks to compare two arrays and output only items unique to either list.
$result = Compare-Object [1] [2] [3]
Use -ReferenceObject and -DifferenceObject to specify arrays, and -PassThru to output only the differing items.