Created
September 15, 2015 20:36
-
-
Save Dalmirog-zz/a84e98d39ba88431e21f to your computer and use it in GitHub Desktop.
Get all the variables scoped to a specific machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #This script required the Octoposh module: http://dalmirog.github.io/OctoPosh/ | |
| $machine = "" #Name of the machine you want to look variables for. | |
| $MachineID = Get-OctopusMachine -MachineName $machine -ResourceOnly | select -ExpandProperty Id | |
| $variableSets = Get-OctopusVariableSet | |
| $list = @() | |
| foreach ($variableSet in $variableSets){ | |
| Foreach ($var in $variableSet.resource.variables){ | |
| If($var.scope.Values -ne 0){ | |
| [string[]]$scope = $var.Scope.Values | |
| $scope = $scope.split(" ") | |
| If ($Scope -match $MachineID){ | |
| $obj = [PSCustomObject]@{ | |
| ProjectName = $variableSet.ProjectName | |
| LibrarySetName = $variableSet.LibraryVariableSetName | |
| VariableName = $var.Name | |
| VariableValue = $var.Value | |
| } | |
| $list += $obj | |
| } | |
| } | |
| } | |
| } | |
| $list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a slightly altered version that dumps all variables to a CSV file: