Created
June 5, 2025 13:26
-
-
Save rfennell/3fb21ce54d9baed33fcca0465f933b51 to your computer and use it in GitHub Desktop.
A PowerShell script to generate SQL commands to update inherited 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
| param ( | |
| $logfile = "DataMigrationTool.log", | |
| $tpcUrl = "http://server:8080/tfs/defaultcollectio", | |
| $outputFile = "update-fields.sql" | |
| ) | |
| $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("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 "-- SQL script to update the WITD" -Force | |
| $Errors.GetEnumerator() | foreach-object { | |
| Add-content -Path $outputFile -Encoding utf8 -value "UPDATE [dbo].[tbl_Field] SET [Name] = '$($_.value)', [ReportingName] = '$($_.value)' WHERE [ReferenceName] = '$($_.key)'" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment