Skip to content

Instantly share code, notes, and snippets.

@DexterPOSH
Last active April 13, 2020 11:32
Gist with a catch
$url = 'https://dev.azure.com/ddhami/BITPro.AzDeploy/_apis/distributedtask/environments'
$cred = Get-Credential -UserName 'vsts' -Message 'Enter AzDO Personal Access Token with privs to create env'
$encodedValue = [Convert]::ToBase64String(
[Text.Encoding]::ASCII.GetBytes(
("{0}:{1}" -f '', $cred.GetNetworkCredential().Password)
)
)
$body = @{
name = 'test-pwsh-env';
description = 'test environment from APR'
} | ConvertTo-Json
$headers = @{
Accept = 'application/json;';
Authorization = "Basic {0}" -f $encodedValue
}
Invoke-RestMethod -Method POST -Uri $url -Body $body -Headers $headers -ContentType 'application/json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment