<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Sync often</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/chrisid/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/chrisid/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 04:53:42 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Updating the TF Registry using Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/updating-the-tf-registry-using-powershell</link>
      <pubDate>Mon, 24 May 2010 14:46:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2010/05/24/updating-the-tf-registry-using-powershell/</guid>
      <description><![CDATA[Here's how to update the Team Foundation Registry using Powershell and the TFS client OM. Visual...]]></description>
      <content:encoded><![CDATA[<p>Here's how to update the Team Foundation Registry using Powershell and the TFS client OM. Visual Studio 2010 and Team Foundation Server 2010 don't ship with a TF equivalent to regedit.exe, so you may need to use Powershell, a .Net language, a TFS Powertool or a third-party tool.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">I'm <span style="FONT-WEIGHT: bold">not</span> referring to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\*\TeamFoundation in the Windows Registry on client machines. The Team Foundation Registry is totally separate from the Windows Registry. The Team Foundation registry is stored across the configuration and collection databases.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">I've made some other posts that include TF registry changes, but I'm dedicating this entry to making any change to the TF registry. To make this example as general as possible, I'll pretend I want to set the path /Configuration/ExampleService/DefaultWidgetTemplate to FabrikamWidget, delete the path /Configuration/ExampleService/MaxWidgetsPerHectometer and its associated value. I'm using these like Foo, Bar and Baz - they're stand-ins for the actual paths you're interested in modifying.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">For a list of actual TF Registry paths and values used by the product code, see <a href="https://blogs.msdn.com/chrisid/archive/2010/05/24/list-of-tf-registry-paths.aspx">https://blogs.msdn.com/chrisid/archive/2010/05/24/list-of-tf-registry-paths.aspx</a></p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Updating a value in the configuration hive</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">#Update configuration URL as necessary</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer "<a href="https://localhost:8080/tfs/">https://localhost:8080/tfs/</a>"</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Get the configuration hive.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configHive = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Browse the TF Registry Hive API.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configHive | gm</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># See the current settings for the ExampleService.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configHive.ReadEntries("/Configuration/ExampleService/**") | select Path, Value | ft -a</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Update these settings.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configHive.SetValue("/Configuration/ExampleService/DefaultWidgetTemplate", "FabrikamWidget")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configHive.DeleteEntries("/Configuration/ExampleService/MaxWidgetsPerHectometer")</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Updating a value in a collection hive</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">#Update the team project collection URL as necessary</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$projectCollection = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection "<a href="https://localhost:8080/tfs/DefaultCollection">https://localhost:8080/tfs/DefaultCollection</a>"</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Get the collection hive.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionHive = $projectCollection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Browse the TF Registry Hive API.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionHive | gm</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># See the current settings for the ExampleService.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionHive.ReadEntries("/Configuration/ExampleService/**") | select Path, Value | ft -a</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Update these settings.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionHive.SetValue("/Configuration/ExampleService/DefaultWidgetTemplate", "FabrikamWidget")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionHive.DeleteEntries("/Configuration/ExampleService/MaxWidgetsPerHectometer")</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Updating a value in almost every collection's hive</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">You probably don't need to do this. In a lot of the places in the TFS 2010 product code where we read a collection-level setting, we use fall-through to check the same path in the configuration hive. See my blog post <a href="https://blogs.msdn.com/chrisid/archive/2010/03/05/faster-delivery-of-notifications.aspx">TFS 2010: Faster Delivery of Notifications</a> for example. This is equivalent to code first checking HKEY_CURRENT_USER for a setting and then HKEY_LOCAL_MACHINE before finally using whatever default shipped with the product.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">If you really do want to modify the TF registry for almost every collection see my previous blog post, <a href="https://blogs.msdn.com/chrisid/archive/2010/05/21/performing-the-same-operation-against-nearly-every-collection.aspx">Performing the same operation against nearly every collection</a> .</p>]]></content:encoded>
    </item>
    <item>
      <title>List of TF Registry Paths</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/list-of-tf-registry-paths</link>
      <pubDate>Mon, 24 May 2010 14:43:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2010/05/24/list-of-tf-registry-paths/</guid>
      <description><![CDATA[Below is a list of TF Registry paths we've blogged about or otherwise documented. I'll update this...]]></description>
      <content:encoded><![CDATA[<p>Below is a list of TF Registry paths we've blogged about or otherwise documented. I'll update this entry as I hear about new blog posts. The default value column refers to the value hardcoded into the product code, the one used if there is no value in the registry table in the database. This default value may change from release to release. For example <span style="FONT-WEIGHT: bold">NotificationJobDelay</span> will likely change from 120 seconds in TFS 2010 RTM to something closer to zero seconds in a future release.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">To&nbsp;view or set one of these TF registry values, see <a href="https://blogs.msdn.com/chrisid/archive/2010/05/24/updating-the-tf-registry-using-powershell.aspx">https://blogs.msdn.com/chrisid/archive/2010/05/24/updating-the-tf-registry-using-powershell.aspx</a></p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<div sizset="0" sizcache="5" style="DIRECTION: ltr">
<table valign="top" cellpadding="0" cellspacing="0" border="1" style="width: 900px; border-collapse: collapse; direction: ltr; border: #a3a3a3 1px solid;">
<tbody>
<tr>
<td style="width: 1.336in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Product Area</p>
</td>
<td style="width: 1.438in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Configuration-level Setting,</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Collection-level Setting</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">or Both?</p>
</td>
<td style="width: 4.93in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">TF Registry Path</p>
</td>
<td style="width: 0.895in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">TFS 2010 RTM Default Value</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">(subject to change in a future release) </p>
</td>
<td style="width: 2.535in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Description</p>
</td>
<td style="width: 1.55in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Blog Entries</p>
</td>
</tr>
<tr>
<td style="width: 1.336in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Framework</p>
</td>
<td style="width: 1.438in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Both</p>
</td>
<td style="width: 4.93in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">/Configuration/JobService/DefaultDelayedJobDelay</p>
</td>
<td style="width: 0.895in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">120</p>
</td>
<td style="width: 2.535in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">The default number of seconds to delay jobs queued on-demand via QueueDelayedJob.</p>
</td>
<td style="width: 1.55in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt"><a href="https://blogs.msdn.com/chrisid/archive/2010/03/05/faster-delivery-of-notifications.aspx">TFS 2010: Faster Delivery of Notifications (chrisid)</a></p>
</td>
</tr>
<tr>
<td style="width: 1.336in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Framework</p>
</td>
<td style="width: 1.438in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Both</p>
</td>
<td style="width: 4.93in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">/Service/Integration/Settings/NotificationJobDelay</p>
</td>
<td style="width: 0.895in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">120</p>
</td>
<td style="width: 2.535in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">The number of seconds to delay the "Team Foundation Server Event Processing" job by, following a client action like a checkin or work item change.</p>
</td>
<td style="width: 1.55in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt"><a href="https://blogs.msdn.com/chrisid/archive/2010/03/05/faster-delivery-of-notifications.aspx">TFS 2010: Faster Delivery of Notifications (chrisid)</a></p>
</td>
</tr>
<tr>
<td style="width: 1.336in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Framework</p>
</td>
<td style="width: 1.438in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Both</p>
</td>
<td style="width: 4.93in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">/Service/Integration/Settings/NotificationJobLogLevel</p>
</td>
<td style="width: 0.895in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">0</p>
</td>
<td style="width: 2.535in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">The level of logging for the "Team Foundation Server Event Processing" job.</p>
</td>
<td style="width: 1.55in; vertical-align: top; border: #a3a3a3 1pt solid; padding: 4pt;">
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt"><a href="https://blogs.msdn.com/granth/archive/2009/10/28/tfs2010-diagnosing-email-and-soap-subscription-failures.aspx">TFS2010: Diagnosing Email and SOAP subscription failures (granth)</a></p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt"><a href="https://blogs.msdn.com/chrisid/archive/2010/02/15/introducing-the-tfs-background-job-agent-and-service.aspx">TFS 2010: Introducing the TFS Background Job Agent and Service (chrisid)</a></p>
</td>
</tr>
</tbody>
</table>
</div>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Performing the same operation against nearly every collection</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/performing-the-same-operation-against-nearly-every-collection</link>
      <pubDate>Fri, 21 May 2010 14:38:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2010/05/21/performing-the-same-operation-against-nearly-every-collection/</guid>
      <description><![CDATA[Let's say you have an action you want to perform against nearly every collection on your TFS...]]></description>
      <content:encoded><![CDATA[<p>Let's say you have an action you want to perform against nearly every collection on your TFS instance. For example, maybe you just fixed an issue with your mail server and want to force the "Team Foundation Server Event Processing" job for each collection to run soon. (By default it runs every 30 minutes if there are no client actions like checkins triggering it.)</p>
<p>Below are Powershell examples you can customize. When you are operating on several collections you should be prepared for some to be offline, unless you know otherwise. I use trap below to handle this expected condition.</p>
<p>Which example do you want to use? If you're an instance-level TFS administrator and you're performing an administrative action, use the ITeamProjectCollectionService. Otherwise, use the catalog. Taylor Lafrinere covers this in more detail in <a href="https://blogs.msdn.com/taylaf/archive/2010/01/26/retrieve-the-list-of-team-project-collections-from-tfs-2010-client-apis.aspx">one of his blog posts</a>. I'm mainly converting his C# examples into Powershell examples here. </p>
<p>Why "nearly" every collection? See my caveats below.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Using the ITeamProjectCollectionService.</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Three caveats:</p>
<ul type="disc" style="MARGIN-TOP: 0in; unicode-bidi: embed; DIRECTION: ltr; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in">
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">You have to be highly privileged to get a list of team project collections using the ITeamProjectCollectionService. Otherwise you will see "Access Denied: MYDOMAIN\jdoe needs the following permission(s) to perform this action: Edit instance-level information".</span></li>
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">This only operates against started collections. If an administrator has stopped a collection, you can't operate against it using the client OM.</span></li>
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">This only operates against existing collections. If you're adding something custom to each collection like a new job definition, you may want to rerun this code every time a new collection is created or attached.</span></li>
</ul>
<p style="MARGIN: 0in 0in 0in 0.75in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Notes: </p>
<ul type="disc" style="MARGIN-TOP: 0in; unicode-bidi: embed; DIRECTION: ltr; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in">
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Rather than trapping<span style="mso-spacerun: yes">&nbsp; </span>TeamFoundationServiceUnavailableException we could use if ($_.State -eq "Started") { &hellip; }. I use trap here to mirror the code below.</span></li>
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">I've highlighted the code you'll want to customize.</span></li>
</ul>
<p style="MARGIN: 0in 0in 0in 0.75in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Code:</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">#Update configuration URL as necessary</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer <span style="BACKGROUND: yellow; mso-highlight: yellow">"</span><a href="https://localhost:8080/tfs/"><span style="BACKGROUND: yellow; mso-highlight: yellow">https://localhost:8080/tfs/</span></a><span style="BACKGROUND: yellow; mso-highlight: yellow">"</span></p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionService = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamProjectCollectionService])</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$collectionService.GetCollections() | %{</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$collectionName = $_.Name </p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$collectionId = $_.Id</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>trap [Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException]</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>write-warning ("Skipping project collection "+ $collectionName +" ("+ $collectionId +"): "+ $_.Exception.Message)</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>continue</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&amp;{</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>$projectCollection = $configServer.GetTeamProjectCollection($collectionId)</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># Check that we can access the team project collection.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>$projectCollection.Connect("None")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>write-host</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>write-host ("* Operating on project collection "+ $collectionName +" ("+ $collectionId +").")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># Now do your per-collection action.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># For example, queue the "Job History Cleanup Job" for this collection</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># $jobService = $projectCollection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationJobService])</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># $jobService.QueueDelayedJob('8fc76967-da5d-4d53-937b-e3efc6af0fcb')<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="BACKGROUND: yellow; mso-highlight: yellow"># Your code here.</span></p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">}</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Using the TFS Catalog: </p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Three caveats:</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<ul type="disc" style="MARGIN-TOP: 0in; unicode-bidi: embed; DIRECTION: ltr; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in">
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">This only operates on collections you're allowed to see. ITeamProjectCollectionService.GetCollections() requires high-privileges and returns every collection. The catalog requires normal privileges and may only return some of the collections in the system.</span></li>
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Like the example above, this only operates against started collections. If an administrator has stopped a collection, you can't operate against it using the client OM.</span></li>
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Like the example above, this only operates against existing collections. If you're adding something custom to each collection like a new job definition, you may want to rerun this code every time a new collection is created or attached.</span></li>
</ul>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Notes:</p>
<ul type="disc" style="MARGIN-TOP: 0in; unicode-bidi: embed; DIRECTION: ltr; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in">
<li style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><span style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">I've highlighted the code you'll want to customize.</span></li>
</ul>
<p style="MARGIN: 0in 0in 0in 0.75in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Code:</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">#Update configuration URL as necessary</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer<span style="BACKGROUND: yellow; mso-highlight: yellow"> "</span><a href="https://localhost:8080/tfs/"><span style="BACKGROUND: yellow; mso-highlight: yellow">https://localhost:8080/tfs/</span></a><span style="BACKGROUND: yellow; mso-highlight: yellow">"</span></p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$configServerNode = $configServer.CatalogNode;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Query the children of the configuration server node for all of the team project collection nodes</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tpcNodes = $configServerNode.QueryChildren(</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[Guid[]] @( [Microsoft.TeamFoundation.Framework.Common.CatalogResourceTypes]::ProjectCollection ), </p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$false,</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>"None");</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tpcNodes | %{ $_.Resource } | %{</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$collectionName = $_.DisplayName </p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$collectionId = $_.Properties["InstanceId"]</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>trap [Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException]</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>write-warning ("Skipping project collection "+ $collectionName +" ("+ $collectionId +"): "+ $_.Exception.Message)</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>continue</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&amp;{</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>$projectCollection = $configServer.GetTeamProjectCollection($collectionId)</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># Check that we can access the team project collection.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>$projectCollection.Connect("None")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>write-host</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>write-host ("* Operating on project collection "+ $collectionName +" ("+ $collectionId +").")</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">&nbsp;</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># Now do your per-collection action.</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span># For example, queue the "Job History Cleanup Job" for this collection</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# </span>$jobService = $projectCollection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationJobService])</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# </span>$jobService.QueueDelayedJob('8fc76967-da5d-4d53-937b-e3efc6af0fcb')</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="BACKGROUND: yellow; mso-highlight: yellow"># Your code here.</span></p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</p>
<p style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">}</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS 2010: Canceling client requests</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/tfs-2010-canceling-client-requests</link>
      <pubDate>Mon, 05 Apr 2010 13:17:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2010/04/05/tfs-2010-canceling-client-requests/</guid>
      <description><![CDATA[&nbsp; 
Below is&nbsp;an example of canceling a client request using Powershell and the client OM....]]></description>
      <content:encoded><![CDATA[&nbsp; 
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt">Below is&nbsp;an example of canceling a client request using Powershell and the client OM. In this example I have a request in mind and already know which collection it's against. While this is intended to serve as example to make you more familiar with our client OM and the Team Foundation Administration Service, I've highlighted the lines you'd want to alter to cancel a request on your system.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<BLOCKQUOTE>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt" mce_keep="true"># Step 1: View the current requests.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt" mce_keep="true">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</P></BLOCKQUOTE>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Modify the TFS configuration server URL as necessary.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">"</SPAN><A href="https://localhost:8080/tfs/" mce_href="https://localhost:8080/tfs/"><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">https://localhost:8080/tfs/</SPAN></A><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">"</SPAN></P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Modify the collection URL as necessary.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$collection = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">"</SPAN><A href="https://localhost:8080/tfs/DefaultCollection" mce_href="https://localhost:8080/tfs/DefaultCollection"><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">https://localhost:8080/tfs/DefaultCollection</SPAN></A><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">"</SPAN></P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Get the TF administration service.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$adminService = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.IAdministrationService])</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Browse the TF administration service API.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$adminService | gm</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Get the active requests for the collection of interest.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$adminService.QueryActiveRequests($collection, $true).ActiveRequests</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Step 2: Cancel a request.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">#&nbsp;Note the id of the request you want to cancel.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$requestId = <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">1234</SPAN></P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Cancel the request.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$adminService.CancelRequest($collection.InstanceId, $requestId, <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">"tf dir $/ /recursive is going to return millions of rows. Refine your query"</SPAN>)</P>]]></content:encoded>
    </item>
    <item>
      <title>TFS 2010: Faster Delivery of Notifications</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/tfs-2010-faster-delivery-of-notifications</link>
      <pubDate>Fri, 05 Mar 2010 14:57:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2010/03/05/tfs-2010-faster-delivery-of-notifications/</guid>
      <description><![CDATA[In my previous blog post I described the job service, new for TFS 2010. There's an overhead in...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt">In <A href="https://blogs.msdn.com/chrisid/archive/2010/02/15/introducing-the-tfs-background-job-agent-and-service.aspx" mce_href="https://blogs.msdn.com/chrisid/archive/2010/02/15/introducing-the-tfs-background-job-agent-and-service.aspx">my previous blog post</A> I described the job service, new for TFS 2010. There's an overhead in queuing a job, having the job agent acquire it, creating an instance of the associated plugin and releasing the job. To make things more efficient we delay the notification job and batch the notifications. (See the description of QueueDelayedJob in the previous post.) While your server is under high usage the notification job is running every two minutes (by default),&nbsp;sending emails and making SOAP calls. When your server goes idle the notification job stops getting delay-queued.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt">This delay is new to TFS 2010. TFS 2008 sent emails and made SOAP calls immediately. So if you're simply wondering "is something wrong with my system? Is it running slowly?" - don't worry, a two minute delay is expected. If however you rely on immediate notifications and find a two minute delay unacceptable, read on.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt">The notification delay can be set in the TF registry. Here's how you can set it to 30 seconds using Powershell:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Arial; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Modify the&nbsp;TFS configuration server URL as necessary.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer "<A href="https://localhost:8080/tfs/" mce_href="https://localhost:8080/tfs/">https://localhost:8080/tfs/</A>"</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Get the TF registry service.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$tfsRegService = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"># Set the notification delay to 30 seconds. All collections will use this delay unless they override this value in the collection hive.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">$tfsRegService.SetValue("/Service/Integration/Settings/<SPAN style="FONT-WEIGHT: bold">NotificationJobDelay</SPAN>", 30)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">You can take the notification delay lower to that. You can take it to 15 seconds or even zero seconds if that's necessary. I'm not warning that you shouldn't make this change, but you are making your system slightly less efficient. If you have several user actions a second (checkins, work item changes, etc) you may want a delay of at least a few seconds. That way the notification job will find several notifications to deliver each time it runs and there's less overhead per user action.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">There are some TF registry settings our server OM monitors for changes. This is not one of them. <SPAN style="FONT-WEIGHT: bold">You will need to restart the TFS WebApp to reread this setting.</SPAN> You can do an iisreset or recycle the Microsoft Team Foundation Server Application Pool in IIS Manager. (Touching the web.config also seems to work in practice.)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">There's a related setting to mention:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>/Configuration/JobService/<SPAN style="FONT-WEIGHT: bold">DefaultDelayedJobDelay</SPAN>. If NotificationJobDelay isn't set, DefaultDelayedJobDelay's value is used. If DefaultDelayedJobDelay isn't set, it defaults to 120 seconds. (Yes there is a default default delayed-job delay value. I know it’s a horrible name, but that's what it is!)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">We see DefaultDelayedJobDelay as big dial that you tune to your environment. If you need jobs to run immediately, you crank it closer to zero. If you need to handle lots of user activity on low-end hardware, you crank it higher so that more work gets batched and jobs run less often. But we know administrators will need fine-grained control over some jobs, hence optional settings like NotificationJobDelay.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Note that you can set NotificationJobDelay or DefaultDelayedJobDelay at the team project collection-level or the configuration server-level. Our code first attempts to read the setting at the collection hive. It falls back to checking the configuration hive. Here's the order in which we check for the notification job delay:</P>
<OL>
<LI>
<DIV style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">NotificationJobDelay at the collection-level. (Assuming you're dealing with a collection-level action like a checkin or a work item modification.)</DIV></LI>
<LI>
<DIV style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">NotificationJobDelay at the configuration server-level.</DIV></LI>
<LI>
<DIV style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">DefaultDelayedJobDelay at the collection-level. (Assuming you're dealing with a collection-level action like a checkin or a work item modification.)</DIV></LI>
<LI>
<DIV style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">DefaultDelayedJobDelay at the configuration server-level.</DIV></LI>
<LI>
<DIV style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Default to 120 seconds.</DIV></LI></OL>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>TFS 2010: Introducing the TFS Background Job Agent and Service</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/tfs-2010-introducing-the-tfs-background-job-agent-and-service</link>
      <pubDate>Mon, 15 Feb 2010 15:22:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2010/02/15/tfs-2010-introducing-the-tfs-background-job-agent-and-service/</guid>
      <description><![CDATA[Historical Background 
&nbsp;
TFS 2008's Application Tier had two Windows services:

Visual...]]></description>
      <content:encoded><![CDATA[<STRONG>Historical Background</STRONG> 
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">TFS 2008's Application Tier had two Windows services:</P>
<UL style="MARGIN-TOP: 0in; unicode-bidi: embed; DIRECTION: ltr; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in" type=circle>
<LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><SPAN style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Visual Studio Team Foundation Server Task Scheduler (TFSServerScheduler)</SPAN></LI>
<LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"><SPAN style="FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Code Coverage Analysis Service (CoverAn)</SPAN></LI></UL>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">In TFS 2008, the TFS web application (hosted by w3wp.exe) performed some periodic tasks independent of end user requests. One example is an hourly identity sync with AD. Some user requests caused work to be done asynchronously - checking in started versioned file deltification running on another thread. (As a side note, I find "TFS WebApp" ambiguous given that we also have the Proxy WebApp and the TSWA WebApp. If you can think of a better name let me know.)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">In TFS 2010, we're dedicating the TFS WebApp soley to user requests and offloading those periodic tasks and asynchronous work to another process. Configuring the Application Tier installs the "Visual Studio Team Foundation Background Job Agent" (TFSJobAgent). The TFS Job Agent replaces 2008's TFSServerScheduler service. A plug-in to the job agent replaces 2008's CoverAn service. Identity sync and versioned file deltification is performed by other plug-ins.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">We're even using the job agent for some new longer-running end user actions. Team Project Collection creation is performed by the job agent. If you use the client OM to create a collection, it contacts the WebApp to queue the creation and then polls for progress. </P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Overview</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">The TFS Job Agent executes jobs via plug-ins. Plug-in classes implement the Run method in ITeamFoundationJobExtension. Assemblies with one or more<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>job plug-ins are placed in %ProgramFiles%\Microsoft Team Foundation Server 2010\Application Tier\TFSJobAgent\plugins\.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In TFS 2010 the job agent uses reflection to load each DLL under this directory and find job extensions. In a later release we might move to a manifest of plug-in classes or assemblies. When a plug-in finishes execution it returns a result (Succeeded, Partially Succeeded, Failed, …) and a result message.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-SIZE: 11pt"><SPAN style="FONT-FAMILY: Calibri">The job agent runs on the AT using the same service account as the WebApp. The job agent has direct access to the data tier(s), same as the WebApp. For that reason, most of the TFS job extensions use the server object models to access the data tier directly, as opposed to using the client object models and making web requests to the TFS webApp. By the way, if you're familiar with the TFS client OMs you'll find that TFS 2010's server OMs are similar. (Client: </SPAN><SPAN style="FONT-FAMILY: Consolas">myTeamFoundationServer.GetService(VersionControlServer)</SPAN><SPAN style="FONT-FAMILY: Calibri">; Server: </SPAN><SPAN style="FONT-FAMILY: Consolas">requestContext.GetService&lt;TeamFoundationVersionControlService&gt;()</SPAN><SPAN style="FONT-FAMILY: Calibri">)</SPAN></P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Before a job can be run it has to be defined. A<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>JobDefinition has a JobId, a display name, and an ExtensionName. The ExtensionName is the fully-qualified plug-in class name. A JobDefinition optionally has XML JobData and a schedule. The JobId is a GUID. For many of our jobs the JobId is constant and well-known; we can queue Code Churn just by doing jobService.QueueJobNow(CodeChurnConstants.CodeChurnJobGuid).</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Jobs run because of their schedule or because they are queued. Many TFS jobs like code churn are queued in response to a user action like checkin, but also have a backup schedule (every 15-60 minutes). The backup schedule is used to ensure code churn runs in the event where your checkin gets committed but the WebApp crashes prior to code churn getting queued.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">We also have the concept of "delayed queuing". Yes, this is an oxymoron.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>But when a JobDefinition has a schedule it generally indicates that the job runs periodically: at the top of the hour, daily at 3am UTC, etc.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>By delay-queuing a job you're requesting that it run within the next N seconds. Also a job with an EnabledState of SchedulesDisabled will still run when it is delay-queued.<BR></P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">A given job has one of five states: In progress (Running, Paused, Stopping, …), queued, scheduled for future execution, host-blocked&nbsp;or not scheduled. A job is host-blocked because the host/team project collection&nbsp;it is associated with is offline or dormant. When that host becomes active that job will return to queued or scheduled depending on its QueueTime. When a job completes the result and result message are recorded and kept for 31 days (by default). This state and the job results are all maintained on the data tier.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Job Service API</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">The client OM is Microsoft.TeamFoundation.Framework.Client.<SPAN style="FONT-WEIGHT: bold">ITeamFoundationJobService</SPAN>. The server OM is Microsoft.TeamFoundation.Framework.Server.<SPAN style="FONT-WEIGHT: bold">TeamFoundationJobService</SPAN>. You'll find more convenience overloads in the client OM but you can accomplish the same things with either OM.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">To get a list of existing job definitions, use <SPAN style="FONT-WEIGHT: bold">QueryJobs</SPAN>. You can also use this to get a particular job definition if you already know the JobId.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">To check out the results of prior job executions, use <SPAN style="FONT-WEIGHT: bold">QueryJobHistory</SPAN> or <SPAN style="FONT-WEIGHT: bold">QueryLatestJobHistory</SPAN>.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">To queue a job, use <SPAN style="FONT-WEIGHT: bold">QueueJobsNow</SPAN> or <SPAN style="FONT-WEIGHT: bold">QueueDelayedJobs</SPAN>.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">To delete, create or update job definitions, use <SPAN style="FONT-WEIGHT: bold">DeleteJobs</SPAN> or <SPAN style="FONT-WEIGHT: bold">UpdateJobs</SPAN>.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">If you want to create a job definition and queue it for one execution in a single call, check out <SPAN style="FONT-WEIGHT: bold">QueueOneTimeJob</SPAN>. The job definitions created by QueueOneTimeJob get deleted after 7 days by default. This is intended for when each time you execute a job plug-in you supply it with different JobData.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Powershell Client OM Example - Fix Email Notifications</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Let's say you're not getting email notifications, even though you've set up project alerts through Team Explorer. Grant describes <A href="https://blogs.msdn.com/granth/archive/2009/10/28/tfs2010-diagnosing-email-and-soap-subscription-failures.aspx" mce_href="https://blogs.msdn.com/granth/archive/2009/10/28/tfs2010-diagnosing-email-and-soap-subscription-failures.aspx">how to diagnose notification failures</A> primarily using SQL. I'll show you how you can investigate without even getting access to the AT.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Let's first check out the last job result:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Modify the collection URL as necessary.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tpc = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection "<A href="https://localhost:8080/tfs/DefaultCollection" mce_href="https://localhost:8080/tfs/Collection0">https://localhost:8080/tfs/DefaultCollection</A>"</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$jobService = $tpc.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationJobService])</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Browse the API</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$jobService | gm</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Look for the "Team Foundation Server Event Processing" job - you don't have the JobId handy.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$<STRONG>jobService.QueryJobs</STRONG>() | sort Name | select JobId, Name | ft -a</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Get the latest non-successful result.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># (Notifications get deleted after so many delivery attempts, so the job may occasionally succeed when it has no emails to send.)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$<STRONG>jobService.QueryJobHistory</STRONG>([Guid[]] @('a4804dcf-4bb6-4109-b61c-e59c2e8a9ff7')) | ?{ $_.Result -ne "Succeeded" } | select -last 1</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">You see this:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">HistoryId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 46</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">EndTime<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 2/11/2010 4:41:57 PM</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">ResultMessage<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: There were errors or warnings during notification delivery.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>0/1 emails delivered.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>0/0 soap notifications delivered.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>1 errors.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>0 warnings.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="BACKGROUND: yellow; mso-highlight: yellow"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Set /Service/Integration/Settings/NotificationJobLogLevel in the TF registry to 2 to see errors and warnings.</SPAN></P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">JobSource<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: bc9cc30d-4a57-4ef8-ae37-7507c5efee57</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">JobId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: a4804dcf-4bb6-4109-b61c-e59c2e8a9ff7</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">QueueTime<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 2/11/2010 4:41:54 PM</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">ExecutionStartTime : 2/11/2010 4:41:55 PM</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">AgentId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: ba2e59f8-dae1-4f75-9416-1225ed06a69b</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">Result<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: Failed</SPAN></P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Okay let's get more detailed errors by using the registry service to increase the log level:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tfsRegService = $tpc.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Browse the API</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tfsRegService | gm</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tfsRegService.SetValue("/Service/Integration/Settings/NotificationJobLogLevel", 2)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Do something like checking in to produce another notification and switch back to the job service:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Force the job to run again immediately</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># (Team Foundation Server Event Processing gets delay queued, so you'll have to wait up to 2 minutes otherwise.)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$<STRONG>jobService.QueueJobNow</STRONG>([Guid] 'a4804dcf-4bb6-4109-b61c-e59c2e8a9ff7', $false)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"># Keep checking for a new job history till you see a new entry.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$<STRONG>jobService.QueryLatestJobHistory</STRONG>([Guid[]] @('a4804dcf-4bb6-4109-b61c-e59c2e8a9ff7'))</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Now you see this:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">HistoryId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 52</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">EndTime<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 2/11/2010 5:04:35 PM</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">ResultMessage<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: There were errors or warnings during notification delivery.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>0/1 emails delivered.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>0/0 soap notifications delivered.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>2 errors.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>0 warnings.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-------------------------------</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>TF271000: An error occurred while attempting to send an e-mail notification to the following address: chrisid@microsoft.com. Ver</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ify that the e-mail notification settings are correct in the Team Foundation Administration Console.</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Notification: CheckinEvent (DeliveryType: EmailHtml; Address: chris@contoso.com)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Exception: System.Net.Mail.SmtpException: Mailbox unavailable. <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">The server response was: 5.7.1 Client does not have permissions to send as this sender</SPAN></P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFa</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>iledRecipientException&amp; exception)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>at System.Net.Mail.SmtpClient.Send(MailMessage message)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>at Microsoft.TeamFoundation.JobService.Extensions.Core.NotificationJobExtension.SendEmail(TeamFoundationRequestContext reques</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>tContext, TeamFoundationNotification notification)</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">JobSource<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: bc9cc30d-4a57-4ef8-ae37-7507c5efee57</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">JobId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: a4804dcf-4bb6-4109-b61c-e59c2e8a9ff7</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">QueueTime<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 2/11/2010 5:04:32 PM</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">ExecutionStartTime : 2/11/2010 5:04:33 PM</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">AgentId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: ba2e59f8-dae1-4f75-9416-1225ed06a69b</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">Result<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: Failed</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">In my case I was using Network Service as the service account for the WebApp and job agent, which doesn't have permission to send emails through our internal SMTP server. I changed the service account and the from address in the TFS Administration Console, checked in, forced the job to run and received an email in my inbox.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Team Foundation Server Event Processing runs often and the result messages are rather large when there are failures at logging level 2. I'm going to return the logging level to the default until our next investigation:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt">$tfsRegService.DeleteEntries("/Service/Integration/Settings/NotificationJobLogLevel")</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">C# Server OM Example - Run cleanup Jobs at a different time of the day</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">TFS has several cleanup jobs that run daily at 3 a.m. UTC. Maybe you're team is active at 3 a.m. UTC, you've noticed an impact from the cleanup jobs and want to run the jobs at 3 p.m. UTC instead.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Warning #1: Try this at your own risk, or better yet just consider it an example. We have not moved our jobs on our production machines and confirmed there are no ramifications.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">Warning #2: There isn't a good way to programmatically identify cleanup jobs. This code is conservative and doesn't touch several daily jobs that could be considered cleanup jobs.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>try</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>using (TeamFoundationRequestContext requestContext = serviceHost.CreateSystemContext())</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>TeamFoundationJobService jobService = requestContext.GetService&lt;TeamFoundationJobService&gt;();</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>IEnumerable&lt;TeamFoundationJobDefinition&gt; allJobs = <STRONG>jobService.QueryJobDefinitions</STRONG>(requestContext, null);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>List&lt;TeamFoundationJobDefinition&gt; modifiedJobs = new List&lt;TeamFoundationJobDefinition&gt;();</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>foreach (TeamFoundationJobDefinition job in allJobs)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// There is no good programmatic way to identify a cleanup job.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// This code is conservative.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if (Regex.IsMatch(job.Name, @"\bcleanup\b", RegexOptions.IgnoreCase))</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Boolean jobModified = false;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>foreach (TeamFoundationJobSchedule schedule in job.Schedule)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if ((schedule.Interval % DAILY) == 0</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&amp;&amp; schedule.ScheduledTime.Hour == 3) // 3 a.m. UTC.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Console.WriteLine("Changing the schedule for {0}.", job.Name);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>schedule.ScheduledTime = schedule.ScheduledTime.AddHours(12); // 3 p.m. UTC instead.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if (!jobModified)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>jobModified = true;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>modifiedJobs.Add(job);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// We could just supply allJobs instead of modifiedJobs, but this avoids the race condition where</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// someone changes a job definition and we revert their changes by supplying the original job definition.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Console.WriteLine("Committing changes to {0} jobs.", modifiedJobs.Count);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><STRONG>jobService.UpdateJobDefinitions</STRONG>(requestContext, null, modifiedJobs);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>catch (HostShutdownException)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Console.WriteLine("Host is offline. Skipping...");</P>
<P style="MARGIN: 0in; FONT-FAMILY: Consolas; FONT-SIZE: 11pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">See attached file for full example.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt; FONT-WEIGHT: bold">More Details</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Unless you disable it, the job agent runs on every AT. If you have an NLB configuration you'll have job agents competing for queued jobs. By default the job agent will run 3 jobs per processor concurrently. So on a quad-core machine a job agent could be running up to 12 jobs at once.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">If you queue a job that wasn't already queued or in-progress, the job agent will probably take about three seconds to start running it if the job queue isn't backed up. You shouldn't take a dependency on this, but its probably what you'll observe for TFS 2010. Queuing a job N times in quick succession doesn't mean that job will run N times. Queuing a job that is already queued is generally a no-op. Assuming a job takes long enough to run, quickly queuing a job 100 times will likely result in the job running once or twice. Your first call to QueueJobNow will queue the job. Maybe some of your following calls will be no-ops. Then the job agent will acquire the job and start running it. The next call to QueueJobNow will mark the in-progress job for re-queuing.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Calls after that while the job is in-progress are again no-ops.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">We added QueueDelayedJob to batch work and incur the overhead of acquiring, running and releasing jobs less. When the Team Foundation Server Event Processing job runs, it can send notification emails about 20 checkins and 40 work item changes and 1 build instead of a single checkin. Calling QueueDelayedJob will never delay job execution. It only makes a job run sooner or is a no-op. QueueJobsNow and QueueDelayedJobs are currently implemented the same way. They're two different methods just to prevent people from supplying a delay <SPAN style="FONT-WEIGHT: bold">and</SPAN> high-priority. Supplying both is somewhat confusing, and I don't think anyone needs to say "This job <SPAN style="FONT-STYLE: italic">will be</SPAN> urgent in 5 minutes."</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Multiple JobDefinitions can reference the same plug-in. In this case the XML JobData will likely be used to supply different arguments to the plug-in. It is not intended that a JobDefinition's JobData will be updated frequently. Say you do this:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">jobService.QueueJobsNow(fooJob);</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">fooJob.Data = newJobData;</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Thread.Sleep(60 * 1000);</P>
<P style="MARGIN: 0in 0in 0in 0.375in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">jobService.QueueJobsNow(fooJob);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt">Will there be two separate executions of the foo job? Probably, but not if the job agent isn't running or the queue is backed up.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In that case the second call to QueueJobsNow is a no-op. If there is only one execution of the job, it will definitely use the new job data. But if there are two executions, the first execution might use the old job data or the new job data. It depends on how quickly the job agent acquires the job and reads the job definition.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Calibri; FONT-SIZE: 11pt" mce_keep="true">&nbsp;</P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/96/39/28/ChangeTimeOfCleanupJobs.cs" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-96-39-28/ChangeTimeOfCleanupJobs.cs">ChangeTimeOfCleanupJobs.cs</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Undoing "Get Latest Version"</title>
      <link>https://docs.microsoft.com/archive/blogs/chrisid/undoing-get-latest-version</link>
      <pubDate>Tue, 12 Jun 2007 16:42:00 GMT</pubDate>
      <dc:creator><![CDATA[chrisid1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/chrisid/2007/06/12/undoing-get-latest-version/</guid>
      <description><![CDATA[To start off my blog, I'm going to talk about a feature I've&nbsp;occasionally wished TF Version...]]></description>
      <content:encoded><![CDATA[<P>To start off my blog, I'm going to talk about a feature I've&nbsp;occasionally wished TF Version Control had, and some alternatives that you may find acceptable.</P>
<P>From the <A class="" href="https://msdn2.microsoft.com/en-us/library/fx7sdeyf(vs.90).aspx" mce_href="https://msdn2.microsoft.com/en-us/library/fx7sdeyf(vs.90).aspx">documentation for "tf.exe get"</A>:</P>
<BLOCKQUOTE>
<P>"If you work in a team development environment, <B>Get</B> is the command you use most frequently because getting every file in the current project synchronizes with your team and makes sure that you have the very latest copy of shared work."&nbsp;</P></BLOCKQUOTE>
<P>What that doesn't mention is sometimes the very latest copy of some code in a&nbsp;dark corner of your workspace will fail to build - horribly.&nbsp; You just&nbsp;did a&nbsp;full sync, built&nbsp;and regret it.&nbsp; You're unwilling or unable to resolve the build issues.&nbsp;If only you could have your old workspace back - you know <EM>that </EM>built.&nbsp; But how do you get it back?&nbsp; "tf undo" undoes pending changes, not&nbsp;the last sync you performed.</P>
<P>If you didn't plan for this, there may not be anything&nbsp;you can do after the fact.&nbsp; If you have an idea of when you last sunc, you can use "Get Specific Version..." with a date or changeset estimate.&nbsp; Maybe you can find a recent successful build on your builds drop share and relate that back to a changeset/date.&nbsp; If syncing and building doesn't take long, maybe you can use trial and error.</P>
<P>Here are some ideas&nbsp;on preparing for&nbsp;a sync in case you've been bitten by this and are now wary:</P>
<UL>
<LI>Use "tf get /preview" to see what&nbsp;changes a&nbsp;full sync will make.&nbsp; Maybe that will help you decide if you're willing to risk syncing.</LI>
<LI>While your workspace is in a good state, figure out when you last sunc.&nbsp; If your workspace has a single root,&nbsp;you can use&nbsp;"tf history /r /version:C1~W /stopafter:1 D:\my\workspace\root" and&nbsp;note the changeset number.&nbsp; This is the changeset number you'll want to return to if you don't like tip.&nbsp;(If you have several roots to your workspace&nbsp;you'll have to run it several times and remember the highest number.) There are some cases where this will be inaccurate because there's no one changeset number or point in time&nbsp;that lines up with&nbsp;the file versions&nbsp;you have in your workspace.&nbsp; For example, you've checked in more recently than you've sunc, you've performed gets that were less than full workspace gets, or you or your team project have "Get Latest on Checkout" turned on.&nbsp; (Credit to Chandru for the tip.)</LI>
<LI>Label all the files in your current workspace. This gets around the limitation of trying to represent your workspace state&nbsp;with a single changeset. (Delete a label before re-using it for this, because file deletions don't get labeled.)</LI>
<LI>If you always sync from the command-line, write a tf.bat wrapper to log tf calls with the date, time, current directory and arguments.&nbsp; You can refer to this log to figure out when you previously sunc.&nbsp; Here's my attempt:</LI></UL>
<BLOCKQUOTE>
<P><STRONG>@echo off</STRONG></P>
<P><STRONG>rem Only log Gets<BR>if /i "%1" neq "get" goto :RUNTF</STRONG></P>
<P><STRONG>rem log to internal\tf_invokes.log, relative to this script's path.<BR>set LOG=%~dp0internal\tf_invokes.log<BR>echo.&gt;&gt;%LOG%</STRONG></P>
<P><STRONG>rem format the date in .Net's SortableDateTimePattern.&nbsp; Like UTC but using the local timezone.<BR>for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%c<BR>set SDTTIME=%TIME%<BR>if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%<BR>set BEGIN=%SDTDATE%T%SDTTIME%</STRONG></P>
<P><STRONG>echo //[%BEGIN% ::&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ] [%CD%] [%*]&gt;&gt;%LOG%</STRONG></P>
<P><STRONG>:RUNTF<BR>rem actually run the command<BR>tf.exe %*<BR>set TFERRORLEVEL=%ERRORLEVEL%</STRONG></P>
<P><STRONG>rem Only log Gets<BR>if /i "%1" neq "get" goto :end</STRONG></P>
<P><STRONG>for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%c<BR>set SDTTIME=%TIME%<BR>if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%<BR>set END=%SDTDATE%T%SDTTIME%</STRONG></P>
<P><STRONG>rem log the end time as well in case its a long running operation.<BR>echo <A href="file://[%25begin%25/">\\[%BEGIN%</A> :: %END%] [%CD%] [%*]&gt;&gt;%LOG%</STRONG></P>
<P><STRONG>:END<BR>exit /b %TFERRORLEVEL%<BR></STRONG></P>
<P><STRONG></STRONG></P></BLOCKQUOTE>]]></content:encoded>
    </item>
  </channel>
</rss>