PowerShell would be an easy approach with which two large readable files like (*.txt) can be compared. When the content in the file is 40 characters long and have 40 thousand lines to compare then usual techniques like excel VLOOKUP will fail. PowerShell’s Compare-Object command comes to the rescue in such scenarios.
Compare-Object
Compare objects as the name indicates can compare two objects in PowerShell. These can be strings, arrays, complex objects. Below is the syntax,

Lets start simple, comparing two arrays. Here ReferenceObject (first object) is $array1 and DifferenceObject (second object) is $array2.
$array1 = 1, 2, 3 // 1,2 is specific to array1 and 3 is common
$array2 = 3, 4, 5 // 4,5 is specific to array2 and 3 is common
Compare-Object $array1 $array2 -IncludeEqual

Output
Output will be of three types as below:
Side Indicator | Definition |
== | Indicates the content is present in both objects |
=> | Indicates the content only exists in the -DifferenceObject (second object) |
<= | Indicates the content only exists in the -ReferenceObject (first object) |
Larger File Comparison
Just like arrays, you can compare two large files. A sample script is below. In the script since we are only looking to find difference, the IncludeEqual flag is removed. Compare-Object can handle much more complex scenarios and even allows to use underlying .NET IComparable interface as detailed in the documentation.
In the script, we are finding the differences and then iterating through the differences to compare it based on different outputs.
#---------------Input---------------
$firstfile= Get-Content "file1.txt"
$secondFile = Get-Content -Path "file2.txt"
$outputFile = "Output.txt"
#----------Script body---------------
$differences = Compare-Object -ReferenceObject $firstfile -DifferenceObject $secondFile
if ($differences) {
Write-Host "Differences found between the two files:"
$differences | ForEach-Object {
if ($_.SideIndicator -eq "<=") {
Write-Host "Only in file1: $($_.InputObject)"
"Only in file1: $($_.InputObject)" >> $outputFile
}
elseif ($_.SideIndicator -eq "=>") {
Write-Host "Only in file2: $($_.InputObject)"
"Only in file2: $($_.InputObject)" >> $outputFile
}
else {
Write-Host "Different lines: $($_.InputObject)"
"Different lines: $($_.InputObject)" >> $outputFile
}
}
}
else {
Write-Host "No differences found between the two files."
}