Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gist showing Pwsh Code snippet to create environments.
$url = ''
$cred = Get-Credential -UserName 'vsts' -Message 'Enter AzDO Personal Access Token with privs to create env'
$encodedValue = [Convert]::ToBase64String(
("{0}:{1}" -f '', $cred.GetNetworkCredential().Password)
$body = @{
name = 'test-pwsh-env';
description = 'test environment from APR'
} | ConvertTo-Json
$headers = @{
Accept = 'application/json;api-version=5.0-preview.1';
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