Created
June 5, 2025 12:45
-
-
Save rfennell/e29cd9250de0eb955c55373721b9f786 to your computer and use it in GitHub Desktop.
A PowerShell script to generate WITAdmin commands to update XML process template WITD display names based on error in an Azure DevOps Migration error log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| aram ( | |
| $logfile = "DataMigrationTool.log", | |
| $tpcUrl = "http://server:8080/tfs/defaultcollection", | |
| $witAdminPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\witadmin.exe", | |
| $outputFile = "update-fields.ps1" | |
| ) | |
| $Errors = @{} | |
| function Get-ItemFromRow { | |
| param ( | |
| $row, | |
| $startString, | |
| $endString | |
| ) | |
| $start =$row.IndexOf($startString) + $startString.Length | |
| $end = $row.IndexOf($endString) | |
| return $row.Substring($start, $end-$start).Trim() | |
| } | |
| Get-Content -Path $logfile -Encoding UTF8 | ForEach-Object { | |
| $row = $_.ToString() | |
| if ($row.Contains("TF402556")) { | |
| $fieldRef = Get-ItemFromRow -row $row -startstring "TF402556: For field" -endstring "to be well defined" | |
| $fieldName = Get-ItemFromRow -row $row -startstring "you must name it" -endstring "and set its type to" | |
| if ($Errors.ContainsKey($fieldRef) -eq $false) { | |
| write-host "Adding translation '$fieldname' for field '$fieldRef'" | |
| $Errors.Add($fieldRef, $fieldName) | |
| } | |
| } | |
| if ($row.Contains("VS403443")) { | |
| $fieldRef = Get-ItemFromRow -row $row -startstring "you must rename field '" -endstring "' to '" | |
| $fieldName = Get-ItemFromRow -row $row -startstring "' to '" -endstring "'. Given name for" | |
| if ($Errors.ContainsKey($fieldRef) -eq $false) { | |
| write-host "Adding translation '$fieldname' for field '$fieldRef'" | |
| $Errors.Add($fieldRef, $fieldName) | |
| } | |
| } | |
| } | |
| Write-host "Saving update commands in script '$outputfile'" | |
| Set-content -Path $outputFile -Encoding utf8 -value "#PowerShell script to update the WITD" -Force | |
| $Errors.GetEnumerator() | foreach-object { | |
| Add-content -Path $outputFile -Encoding utf8 -value "& `"$witadminPath`" changefield /collection:$tpcUrl /n:$($_.Key) /name:`"$($_.value)`" /noprompt" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment