Hi,
I am looking to script the creation of variables based on roles / tenant details…
Hopefully this will make sense
my roles that will require a variable setting … (but only if there isnt a matching variable already)
$roles = @("APP,“WEB”) etc etc
I get all the tenants that belong to the project i am working on
$alltenants = $repository.Tenants.FindAll() | ?{$_.ProjectEnvironments.ContainsKey(“Projects-85”)}
Working with the tenant flags is where i am getting stuck a little … and here is where i’m at … I have created this variable through the UI
Id : 6f50f884-ebc1-0700-01f0-aae66e38ea99
Name : App
Value :
Type : Sensitive
Scope : {[Environment, Environments-64], [TenantTag, Client/CF, Unique Identifier/SIT1]}
IsEditable : True
Prompt :
IsSensitive : True
When i check the tenant
$tenant.ProjectEnvironments
$tenant.TenantTags
I get these values returned
Key : Projects-85
Value : {Environments-64}
I would only need to check the bold items below
Hosting/Azure Shared
Client/CF
Unique Identifier/SIT1
Version/14
Based on what i would need to check there is a matching variable for this tenant and role …
how can i filter returned variables based on the environments or tentant tags … filtering by name is easy i can find all the app variables … but finding variables based on EV/tags is a little tricky …
$variablesetname = “Account Passwords”
$variableset = $repository.LibraryVariableSets.FindByName($variablesetname)
$variableset = $repository.VariableSets.Get($variableset.VariableSetId)
$appvariables = $variableset.Variables | ?{$_.name -match “APP”}
Id : 6f50f884-ebc1-0700-01f0-aae66e38ea99
Name : App
Value :
Type : Sensitive
Scope : {[Environment, Environments-64], [TenantTag, Client/CF, Unique Identifier/SIT1]}
IsEditable : True
Prompt :
IsSensitive : True
Id : d3037077-a535-b364-5fde-d70aa3b20a22
Name : App
Value : testing123
Type : String
Scope : {[Environment, Environments-1], [TenantTag, Client/Vanilla, Unique Identifier/Team1]}
IsEditable : True
Prompt :
IsSensitive : False
so from the tenant details above how can i filter the 2 results down to one based on EV 64
and then tenant tags? as there will be more per EV
I would like to do something similar to
$appvariables = $variableset.Variables | ?{$_.Scope.Environment -contains “Environments-64”} (though that obvs doesn’t work)
let me know if you need any more info on this
Thanks