I'm trying to combine System.IO.FileInfo objects (from distinct Get-ChildItem calls) together. I've found working solutions (i.e. using PowerShell array) from this question: Combine the results of two distinct Get-ChildItem calls into single variable to do the same processing on them
$target = "C:\example"
$Files = @( Get-ChildItem -LiteralPath $target -Force -Attributes !D )
$Files += @( Get-ChildItem -LiteralPath $target -Force -Attributes !D ) # for demo. & simplicity, I'm using the same path here
$Files | Write-Host # here the same entries are duplicated
However, the same entries from the System.IO.FileInfo objects are duplicated in the resulting object. I'm wondering if there is an elegant way to combine the objects while removing the duplicates?
PS: Files are "duplicated" if they have the same ".FullName".