I have a script that checks if an URL from file 1 exists in file 2, and if not, writes it to the output file. It works fine, here it is:
Write-Host "Script output will have unique items from file 1"
$FirstPath = Read-Host -Prompt "Input file location of first .csv file"
$SecondPath = Read-Host -Prompt "Input file location of second .csv file"
Write-Host "Importing CSV files..."
$FirstFile = Import-Csv $FirstPath -Delimiter ';' |
Select-Object -ExpandProperty Url
$SecondFile = Import-Csv $SecondPath -Delimiter ';' |
Select-Object -ExpandProperty ITEM_TARGET_URI
Write-Host "Comparing files..."
Compare-Object -ReferenceObject $FirstFile -DifferenceObject $SecondFile -PassThru |
Where-Object { $_.SideIndicator -eq "<=" } |
Out-File -Encoding Utf8 .\result.txt
Write-Host "Done, press any key to continue..."
$x = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
My issue is, that when working on large CSV files (one has for example 4 000 000 records), the script works a whole night and still isn't finished. I can't also see if there is any progress. I'd like to make it work faster, or at least have some info about progress in work. I've read about progressbar, etc. But it won't work since it is comparing in only 1 line, not in a loop.
What can I change in my script to make it work faster, and/or be able to see progress?
Edit: the problem is different from a thread sugested, I'm mainly focusing on working with large files and improving speed of my script. Solution sugested there is not answering this problem.