Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2012 01:56
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jstangroome/3753534 to your computer and use it in GitHub Desktop.
Force TFS 2012 to synchronize Active Directory group memberships
param (
[Parameter(Mandatory=$true, Position=0)]
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
Add-Type -AssemblyName 'Microsoft.TeamFoundation.Client, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
$Server = [Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory]::GetConfigurationServer($ServerUri)
$JobService = $Server.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationJobService])
$IdentitySyncJobId = [guid]'544dd581-f72a-45a9-8de0-8cd3a5f29dfe'
$IdentitySyncJobDef = $JobService.QueryJobs() |
Where-Object { $_.JobId -eq $IdentitySyncJobId }
if ($IdentitySyncJobDef) {
Write-Verbose "Queuing job '$($IdentitySyncJobDef.Name)' with high priority now"
$QueuedCount = $JobService.QueueJobNow($IdentitySyncJobDef, $true)
if ($QueuedCount -eq 0) {
Write-Error "Failed to queue job"
} else {
Write-Error "Could not find Periodic Identity Synchronization job definition (id $IdentitySyncJobId)."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment