Skip to content

Instantly share code, notes, and snippets.

#The -IncludeUsage switch will populate $VariableSet.Usage with the name of the projects using the LVS
#If -IncludeUsage is not passed, .usage will always be empty
Set-OctopusConnectionInfo -Server http://OctoServer -ApiKey API-XXX
$VariableSets = Get-OctopusVariableSet -LibrarySetName * -IncludeUsage
foreach($VariableSet in $VariableSets){
Write-Output "`nVariable set [$($VariableSet.LibraryVariableSetName)] is being used by projects"
#"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)
@KennethBates
KennethBates / AddVariableSetsToAllProjects.ps1
Created August 22, 2016 12:57
Add Variable Sets to all projects
$OctopusAPIkey = "" #Octopus API Key to authenticate
$OctopusURL = "" #Octopus Server URL
$variableSetId = "" #Variable Set Id you want to add to projects
#Register the Octopus client and Newtonsoft JSON dlls for all this to work
Add-Type -Path "C:\Program Files\Octopus Deploy\Octopus\Newtonsoft.Json.dll"
Add-Type -Path "C:\Program Files\Octopus Deploy\Octopus\Octopus.Client.dll"
#Create a connection to the Octopus server using the URL and the API Key