How to Compare two .txt files using PowerShell?

Good day everyone,

I would like to ask you, how it is possible to compare two .txt files using PowerShell?
I had generate a .txt file before and after some Fix (deploy new version)
And now I would like to verify if the two .txt files are exactly the same or there are some differences.
Many thanks in advance,

my code is here:

[pre]

$dbAddress = “SEH05VVM745”
$CleanDbScriptPath = “D:\AUTOMATION\Scripts\CleanDB.txt”

$CleanDB = “D:\AUTOMATION\Results\CleanedDBTables.txt”

$TablesDbScriptPath = “D:\AUTOMATION\Scripts\TablesDB.txt”

$ImportedFiles = “D:\AUTOMATION\Results\ImportedTables.txt”

#Extract DB tables (sort by table name)
Invoke-Sqlcmd -ServerInstance $dbAddress -InputFile $TablesDbScriptPath | Out-File -FilePath $ImportedFiles
Write-Host “DB Tables has been copied to a .txt file” -ForegroundColor Green

[/pre]

Try Compare-Object command
[PRE]
Compare-Object (Get-Content $TablesDbScriptPath) --DifferenceObject (Get-Content $ImportedFiles)
[/PRE]

Hi @rejikodiyil

Ohhh, I see, I will try.

Many thanks :slight_smile:

Have a nice day