Posted By

michanne on 07/09/11


Tagged

TFS


Versions (?)

Compare TFS Server Paths


 / Published in: Windows PowerShell
 

Compares two TFS paths after $startdate and returns a list of files that are different. First section outputs owner, changeset, servername that are only on the Left side. The second outputs owner, changeset L&R, servername for files that are different. Constrained to files where the Left side change date is after the right side change date.

  1. Add-pssnapin microsoft.teamfoundation.powershell
  2. #snapin from http://pstfs.codeplex.com/
  3. add-pssnapin ServerTFSPSSnapIn
  4. cls ;
  5.  
  6. #variables
  7. $destPath = "$env:USERPROFILE\My Documents\_Development\TFS_Scripts\LeftOnly.txt"
  8. $TFserver = "localhost"
  9. $serverpathL = "$/Data Warehouse/D4.0"
  10. $serverpathR = "$/Data Warehouse/D5.0"
  11. [datetime]$startDate = "1/1/2011"
  12. $tfs = get-tfsServer $TFserver
  13.  
  14. $item = (get-diff -tfs $tfs -pathl $serverpathL -pathr $serverpathR ) |foreach{$_\3|?{($_\3.TypeDiff -eq 'Diff' -or $_\3.TypeDiff -eq 'LeftOnly') -and $_\3.DateCheckInL -ge $startDate }}
  15.  
  16. #Left only Files (Basically the same logic for RightOnly)
  17. if (test-path $DestPath) {del $DestPath}
  18.  
  19. $left = $item | select information,DateCheckInL, TypeDiff, ItemL |?{$_\3.TypeDiff -eq 'LeftOnly'} |sort DateCheckInL -descending
  20. "Owner`tChangeSetID`tDateCheckedIn`tServerItem"|set-content $DestPath
  21. foreach($l in $left) {
  22. $serverItem = $l.Information
  23. $DateCheckedIn = ($l.DateCheckInL).tostring()
  24. $ChangeSetID = $L.ItemL.ChangeSetID
  25. $owner = (get-tfsItemhistory $serverItem -server $tfServer -stopafter 1).Owner
  26. "$owner`t$ChangeSetID`t$DateCheckedIn`t$serverItem"|add-content $DestPath
  27. }
  28. #get-content $DestPath
  29.  
  30. #Diff Files
  31. $destPath = "$env:USERPROFILE\My Documents\_Development\TFS_Scripts\Diff.txt"
  32.  
  33. $diff = (get-diff -tfs $tfs -pathl $serverpathL -pathr $serverpathR) |foreach{$_\3|?{$_\3.TypeDiff -eq 'Diff' -and $_\3.DateCheckInL -ge $startDate -and $_\3.DateCheckInL -gt $_\3.DateCheckInR }}|sort DateCheckInL -descending
  34.  
  35. if (test-path $DestPath) {del $DestPath}
  36.  
  37. "Owner`tD4_ChangeSetID`tD4_DateCheckedIn`tD5_ChangeSetID`tD5_DateCheckedIn`tServerItem"|set-content $DestPath
  38.  
  39. foreach($d in $diff){
  40. $s = $d.Information -split " - "
  41. $L = get-tfsitemproperty $s[0] -server $TFserver -workspace $workspace
  42. $R = get-tfsitemproperty $s[1] -server $TFserver -workspace $workspace
  43. $Owner = (get-tfsItemhistory $L.SourceServerItem -server $tfServer -stopafter 1).Owner
  44. $ChangeSetL = $d | select -ExpandProperty ItemL |select changesetid, checkindate
  45. $ChangeSetR = $d | select -ExpandProperty ItemR|select changesetid, checkindate
  46. "$Owner`t"+ $ChangeSetL.changesetid + "`t" + ($ChangeSetL.CheckinDate).Tostring()+"`t"+$ChangeSetR.changesetid + "`t" + ($ChangeSetR.CheckinDate).Tostring()+"`t"+$L.SourceServerItem |add-content $DestPath
  47. }
  48. #get-content $DestPath
  49.  
  50. #compare-object $(get-content $L.LocalItem) $(get-content $R.LocalItem)

Report this snippet  

You need to login to post a comment.