Skip to content

Instantly share code, notes, and snippets.

@pkutaj
Created March 3, 2021 11:44
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 pkutaj/75df87756af52d854ce1b9e15ced898f to your computer and use it in GitHub Desktop.
Save pkutaj/75df87756af52d854ce1b9e15ced898f to your computer and use it in GitHub Desktop.
query-consul.ps1
function query-consul ([string]$customer, [string]$queryString, [int]$context, [switch]$detailed) {
$consulURL = "https://consul.foo.net/ui/eu-central-1/kv/customer/$customer"
elseif ($detailed) {
consul kv get -recurse -detailed customer/$customer |
Select-String $queryString -Context 1, $context
}
else {
consul kv get -recurse customer/$customer |
Select-String $queryString -Context 1, $context
}
<#
.SYNOPSIS
- Function querying Hashicorp Consul'KV for the a string in question
.DESCRIPTION
- Provide an empty string to query all folders
- Run with -detailed flag to get richer outout
- You can provide -context [int] to get richer output
#>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment