$teamcityFolders = Get-ChildItem -Path C:\CloneAll\DevOps\.teamcity -Directory -Recurse -Depth 4 $fileMap = @{} foreach ($teamcityFolder in $teamcityFolders) { Set-Location -Path (Split-Path -Path $teamcityFolder.FullName -Parent) git reset --hard git checkout main git checkout master git pull origin } Set-Location -Path C:\CloneAll Start-Transcript -Path "z:\temp\SRE-18111.txt" foreach ($teamcityFolder in $teamcityFolders) { $xmlFilesPath = Join-Path -Path $teamcityFolder.FullName -ChildPath "*.xml" $xmlFiles = Get-ChildItem -Path $xmlFilesPath -File -Recurse foreach ($xmlFile in $xmlFiles) { $file = [xml](Get-Content -Path $xmlFile.FullName -Raw) $uuid = $file.ChildNodes[1].uuid if ($null -eq $uuid) { continue } if ($null -eq $fileMap.$uuid) { $fileMap.$uuid = @() } $fileMap.$uuid += @{ Name = $file.ChildNodes[1].name; Path = $xmlFile.FullName; FileName = $xmlFile.Name; } } } foreach ($key in $fileMap.Keys) { if ($fileMap.$key.Count -gt 1) { Write-Host "Distinct uuid: $key" $groups = $fileMap.$key.Name | Group-Object if (@($groups).Count -eq 1) { Write-Host "`tFound one distinct name for all of the following files: $($groups[0].Name)" } else { Write-Host "`tFound multiple names for the following files" foreach ($group in $groups) { Write-Host "`t * $($group.Name)" } } $groups = $fileMap.$key.FileName | Group-Object if (@($groups).Count -eq 1) { Write-Host "`tFound one distinct filename for all of the following files: $($groups[0].Name)" } else { Write-Host "`tFound multiple filenames for the following files" foreach ($group in $groups) { Write-Host "`t * $($group.Name)" } } Write-Host "`t`t$($fileMap.$key.Path -join "`n`t`t")" } } Stop-Transcript