'PowerShell - Find duplicate titles

I need a function that collects the titles from patches and exists and print if there are 2 or more titles that contains one of the $SearchTitles. If I have 2 geo and one Dictionary I want to know about it. If I have 2 Dictionary I want to know. Just one function with 3 inputs (patches,exists.$SearchTitles) The duplication can be found in patches or in exists or in both

The main goal here is to let the user know if there are more than one title that contains one of the $Searchstring and print the number of the patch. For an example if 'Dictionary Update' shows in 2 patch's titles I want to print who holds this. Currently the function combined 2 variables $patches, $exists that holds a list of numbers (I collect them from excel). and for each one of them get the title from the TFS. I don't know how to search for $Searchstring and get the patches that holds the same title Need to compare between all the patches only when there is duplicate of Dictionary Update or Geo Location Enrichment

$Searchstring = "Dictionary Update", "Geo Location Enrichment"
    
$pathesList = @($patches, $exists)
    
function Duplicatepatches($pathesList) {
    foreach ($pathList in $pathesList) {
        foreach ($patch in $pathList) {
            $Title += (Get-VSTeamWorkItem -Id $patch.Patch).fields.'system.Title'  
        }
    }
    $Title
}   

$patches =
Patch
  -----
1315415

$exists =

Patch
  -----
1301707
1292054
1293404
1295392
1298589
1296128
1308438
1310686

    


Sources

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

Source: Stack Overflow

Solution Source