Last active
April 13, 2020 11:32
-
-
Save DexterPOSH/5ab57d63bbbb8241ee05d3893f2ca51e to your computer and use it in GitHub Desktop.
Gist showing Pwsh Code snippet to create environments.
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
$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;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