Hi
I’m trying to update a common variable for all of our tenants with powershell but is getting a responsecode 500. Can you see what is the issue with the following script?
$allTenants = Invoke-WebRequest -uri "https://[instance].octopus.com/api/tenants/all?apikey=API-KEY" | ConvertFrom-Json
foreach($tenant in $allTenants)
{
$tenantVariables = Invoke-WebRequest -uri "https://[instance].octopus.com/api/tenants/$($tenant.Id)/variables?apikey=API-KEY" | ConvertFrom-Json
$tenantVariables.LibraryVariables.'LibraryVariableSets-2'.Variables | Add-Member -NotePropertyName "a9599425-68bb-4978-98b6-df8e39f162c6" -NotePropertyValue $tenant.Name
$jsonTenant = ConvertTo-Json $tenantVariables
Invoke-WebRequest -Uri "https://[instance].octopus.com/api/tenants/$($tenant.Id)/variables?apikey=API-KEY" -Method Put-Body $jsonTenant
}
Regard
Nils