Skip to content

Instantly share code, notes, and snippets.

@KennethBates
Created September 19, 2017 04:34
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 KennethBates/5ea63c01d9ac3813a4b329b89d15bf83 to your computer and use it in GitHub Desktop.
Save KennethBates/5ea63c01d9ac3813a4b329b89d15bf83 to your computer and use it in GitHub Desktop.
#"Variable Set" is the resource name for both the variables in a project and the ones in a Library Variable Set.
#By passing -Projectname * we make sure we only get variable sets that belong to projects and not to libraries.
Set-OctopusConnectionInfo -Server http://OctoServer -ApiKey API-XXX
$allVariableSets = Get-OctopusVariableSet -projectName *
$valueToSearch = "*var*" #Looking for variables with the word *var* anywhere in their values.
foreach ($variableSet in $allVariableSets)
{
write-host "running for project [$($variableSet.ProjectName)]"
$variableFound = $false
foreach ($variable in $variableSet.variables)
{
if ($variable.value -like $valueToSearch)
{
$variableFound = $true
write-host "The variable [$($variable.name)] has the value [$($variable.value)]"
}
}
if ($variableFound -eq $false)
{
write-host "No variable was found for project [$($variableSet.ProjectName)]"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment