'Performing minus from parent to child files using powershell

I have three files in test1 folder:

enter image description here

I have three files in test2 folder:

enter image description here

Common between these two folders is file2.

I want to subtract common files between these two folders and get only unique files from test1 folder.

My expected output is:

file1.txt
file3.txt

I tried using:

cls
$parent='D:\test1'
$child='D:\test2'
$final = [System.Collections.ArrayList]@()


$parentarrays=Get-ChildItem $parent
$childarrays=Get-ChildItem $child

foreach ($p1 in $parentarrays) {
 foreach ($p2 in $childarrays){
   if($p1 -notcontains $p2){
      $final.add($p1)
   }  
 }
 }

 Write-Host $final

But I am getting output:

file1.txt.txt file1.txt.txt file1.txt.txt file2.txt.txt file2.txt.txt file2.txt.txt file3.txt.txt file3.txt.txt file3.txt.txt


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source