Show all pending changes on the Team Foundation server older than a given age

This came up in the forums and Brian responded with an example showing how to list all pending changes.  This is a slightly modified version to print out the changes older than 2 weeks.

    TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(server);

    VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));


    TimeSpan cutoffAge = TimeSpan.FromDays(14); // 2 weeks

    DateTime cutoffPoint = DateTime.Now - cutoffAge;


    PendingSet[] sets = vcs.GetPendingSets(new String[] { "$/" }, RecursionType.Full);

    Console.WriteLine("{0} total pending set(s)", sets.Length);

    foreach (PendingSet set in sets)


        bool setInfoShown = false;

        foreach (PendingChange pc in set.PendingChanges)


            if (pc.CreationDate < cutoffPoint)


                if (!setInfoShown)


                    setInfoShown = true;


                    Console.WriteLine("Workspace {0};{1} on {2} has {3} total pending change(s)", set.Name, set.OwnerName, set.Computer, set.PendingChanges.Length);


                Console.WriteLine("{0,-20} {1,-10} {2,-16} {3}", pc.FileName, pc.ChangeTypeName, pc.CreationDate, pc.LocalItem);




Comments (4)
  1. Buck Hodges says:

    I recently had to put together a list of links to code samples.&amp;nbsp; This isn’t even close to comprehensive,…

  2. Подсистема контроля версий файлов в TFS позволяет работать из командной строки. Находится эта утилита

  3. Buck Hodges says:

    I recently had to put together a list of links to code samples. This isn’t even close to comprehensive,

Comments are closed.

Skip to main content