-
-
Save jakobjs/9b6051d4fb964f1f38571e6fbc1ab0f4 to your computer and use it in GitHub Desktop.
Force TFS 2018 to synchronize Active Directory group memberships
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true, Position=0)] | |
[uri] | |
$ServerUri | |
) | |
$ErrorActionPreference = 'Stop' | |
Set-StrictMode -Version Latest | |
[Reflection.Assembly]::LoadFrom('D:\Program Files\Microsoft Team Foundation Server 2018\Tools\Microsoft.TeamFoundation.Client.dll') | |
$Server = [Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory]::GetConfigurationServer($ServerUri) | |
$Server.EnsureAuthenticated() | |
$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