Ok, so I've gotten this and SOME duplicates, however, it is still NOT
reading all the duplicates.
$file1 = @(get-content d:\File1.csv) | sort
$file2 = @(get-content d:\file2.csv) | sort
compare-object $file2 $file1 -includeequal
Can someone tell me why I may not be getting all the duplicates. I can see
some of the duplicates are exactly the same in the files but the script does
not pick them up
Any suggestions
"Nik" <nalleyne@newsgroup> wrote in message
news:uYTdmyRpKHA.1548@newsgroup
> I have two files "File1" and "File2". I think "File2" may contain some of
> the elements I have in "File1" I wish to compare these two files and
> extract the duplicate Items and put them into a new file. The furthest I
> have gotten is to compare the files and read the individual array items,
> but I can't seem to pull the duplicates. I know there are duplicates but
> still can't get them. all help appreciated. Thanks
>
> $File1 = @(Get-Content D:\File1.csv)
> $File2 = @(Get-Content D:\File2.csv)
> $duplicates =@()
>
> for ( $i=1; $i -le $file1.count; $i++ )
> {
> Write-Host $file1[$i]
> }
>
> for ( $j=1; $j -le $file1.count; $j++ )
> {
> Write-Host $file1[$j]
> }
>
>
> for ( $l=1; $l -le $file1.count; $l++ )
> {
> if ( $file1[$i] -eq $file2[$j] )
> {
> Write-Host "Match Found"
>
> }
> else
> {
> Write-host "Match Not found"
> }
> }
>
>
>
> Write-Host $file1[9]
> write-host $file2[3]
> $File1.Count
> $File2.Count