Skip to content

Instantly share code, notes, and snippets.

@mrled
Created August 31, 2017 01:03
Show Gist options
  • Save mrled/8d0f4ed462e97ac5bda314e22fda7b5d to your computer and use it in GitHub Desktop.
Save mrled/8d0f4ed462e97ac5bda314e22fda7b5d to your computer and use it in GitHub Desktop.
[Show Octopus Variables in Powershell] #powershell #octopus
<#
.synopsis
Show Octopus parameters defined in files
.parameter rootPath
Search recursively from here.
If the tree is large, this command will take a long time. If you're working in a Git repository of a project directory, it might be worth running 'git clean -fxd' beforehand. This will delete all your bin/ and obj/ directories (meaning any binaries you have built will be deleted), but will make this command run faster.
.parameter filePattern
Look for files whose name matches this pattern. By default, only look for *.Octopus.config files.
#>
function Show-OctopusVariables {
[CmdletBinding()] Param(
$rootPath = $pwd.Path,
$filePattern = "*.Octopus.config"
)
$files = Get-ChildItem -Path $rootPath -Recurse -File -Include $filePattern
Select-String -Path $files -Pattern '#{(.*?)}' -AllMatches |
Foreach-Object -Process { $_.matches.groups[1].Value } |
Sort-Object -Unique
}
Show-OctopusVariables @PSBoundParameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment