Sometimes we need to add users to our AD or Windows so we can add them to TFS and have them appear immediately without needing to wait for the synchronization to happen automatically. There are many ways to do that. I will explain how to do that with different methods.
TFS Job Agent is responsible for running this sync and other jobs. By default, this runs once an hour. We can run this job using the Web Service “JobWebService” or by using the TFS Client Object Model “Microsoft.TeamFoundation.Client”. We can use the Client Object Model with a C# Console Application or with a PowerShell script.
Use the JobWebService Directly
We need to call the QueueJobs web service, but unfortunately, we can’t call that from the browser. We also need the GUID of the job.
Open the JobService Web Services and click on the QueueJobs Web Service.
We can’t call it from the browser and we need the GUID of the Job.
Use the WebServiceStudio
We can use a very smart tool, WebServiceStudio, that exists on CodePlex. This tool enables us to call the Web Service with a GUI without writing code for the Web Service.
Use a PowerShell Script
We can also use the TFS Client Object Model “Microsoft.TeamFoundation.Client” with a PowerShell script.
I made the demo on Brian Keller VM. Here are the steps you need to follow:
Add your user to your AD or Local accounts for the workgroup.
Remember that we are adding the Windows Group to the TFS Collection. In our case, it’s the Administrators group.
Run the job using any method, and then the users will start to appear immediately.
View Job Status
To view the status of the job, queue time, start time, or end time, run the following SQL script on the Data Tier (DT). Don’t confuse the time as it is UTC.
1
2
3
4
USE tfs_Configuration
SELECT TOP 100 *
FROM [Tfs_Configuration].[dbo].[tbl_JobHistory]
WHERE JobId='544DD581-F72A-45A9-8DE0-8CD3A5F29DFE'