Skip to content

Instantly share code, notes, and snippets.

@smaglio81
Created June 21, 2020 16:36
Show Gist options
  • Save smaglio81/25f4ad92fdac3082e69338c7b89169b7 to your computer and use it in GitHub Desktop.
Save smaglio81/25f4ad92fdac3082e69338c7b89169b7 to your computer and use it in GitHub Desktop.
# see https://docs.microsoft.com/en-us/azure/devops/integrate/concepts/dotnet-client-libraries?view=azure-devops
# for links to some of the nuget packages which contain these (this code was written against version 15.131.1)
Add-Type -Path "C:\YourPath\Newtonsoft.Json.dll"
Add-Type -Path "C:\YourPath\Microsoft.TeamFoundation.Client.dll"
Add-Type -Path "C:\YourPath\System.Net.Http.Formatting.dll"
Add-Type -Path "C:\YourPath\Microsoft.VisualStudio.Services.Common.dll"
Add-Type -Path "C:\YourPath\Microsoft.VisualStudio.WebApi.dll"
Add-Type -Path "C:\YourPath\Microsoft.VisualStudio.Services.ServiceHooks.dll"
$pat = "your-personal-access-token"
$global:AzDModule = @{}
$global:AzDModule.Uri = "https://dev.azure.com/{your-organization}"
$vssBasicCredential = New-Object -TypeName Microsoft.VisualStudio.Services.Common.VssBasicCredential "", $pat
$global:AzDModule.VssConnection = New-Object `
-TypeName Microsoft.VisualStudio.Services.WebApi.VssConnection `
-ArgumentList @($global:AzDModule.Uri, $vssBasicCredential)
$global:AzDModule.ServiceHooksPublisherClient = $global:AzDModule.VssConnection.GetClient([Microsoft.VisualStudio.Services.ServiceHooks.WebApi.ServiceHooksPublisherHttpClient])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment