Skip to content

Instantly share code, notes, and snippets.

@IlyaFinkelshteyn
Created August 28, 2018 16:40
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 IlyaFinkelshteyn/fb08ac0349c9e18bf67619691fbeb5d4 to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/fb08ac0349c9e18bf67619691fbeb5d4 to your computer and use it in GitHub Desktop.
$env:API_TOKEN = "<replace>" # from https://ci.appveyor.com/api-token
$env:APPVEYOR_ACCOUNT_NAME = "<replace>" # from AppVeyor project URL
$env:APPVEYOR_PROJECT_SLUG = "<replace>" # from AppVeyor project URL
$env:ROLE_NAME = "<replace>" # role to update permissions
$API_URL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings"
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
# get variables collection from server
$s = Invoke-RestMethod -Uri $API_URL -Headers $headers -Method Get
$rights = (($s.settings.securityDescriptor.roleAces | ? {$_.name -eq $env:ROLE_NAME}).accessRights | ? {$_.name -eq "View"})
if ($rights.allowed -ne $null) {$rights.allowed = $true} else {$rights | Add-Member "allowed" $true}
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects' -Headers $headers -Body ($s.settings | ConvertTo-Json -Depth 10) -Method Put
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment