Skip to content

Instantly share code, notes, and snippets.

@johnlokerse
Created February 6, 2022 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlokerse/872c6369f67736d19f92e633ff8ebb9c to your computer and use it in GitHub Desktop.
Save johnlokerse/872c6369f67736d19f92e633ff8ebb9c to your computer and use it in GitHub Desktop.
$Body = @{
"PreviewRun" = "true"
"YamlOverride" =
'
pool:
vmImage: windows-2019
jobs:
- job: Run_PowerShell_Write_Host
steps:
- task: PowerShell@2
inputs:
targetType: "inline"
script: |
Write-Host "Hello World"
'
}
$OrganizationName = "john-lokerse"
$ProjectName = "Blog"
$PipelineId = 11
$Url = "https://dev.azure.com/$OrganizationName/$ProjectName/_apis/pipelines/$PipelineId/runs?api-version=5.1-preview"
$Arguments = @{
Method = "POST"
Uri = $Url
Body = $Body | ConvertTo-Json
ContentType = "application/json"
Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":<YOUR_PAT_HERE>")) }
}
Invoke-RestMethod @Arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment