Skip to content

Instantly share code, notes, and snippets.

@nichollsc81
Created October 21, 2021 09:58
Show Gist options
  • Save nichollsc81/d37290158261ce52bf77cebf9ced1b6d to your computer and use it in GitHub Desktop.
Save nichollsc81/d37290158261ce52bf77cebf9ced1b6d to your computer and use it in GitHub Desktop.
Returns public IPs for given Cloud Elements environment (staging/production)
# collect CE IP ranges
$AllCEIps = (Invoke-RestMethod https://my.cloudelements.io/ip-ranges.json).prefixes
# counter
[int] $Count = 0
# CE Environment: staging / production
[string] $Environment = 'staging'
foreach ($a In $AllCEIps)
{
# extract environment and ip
$obj = [ordered]@{
Env = $a.environment
Ip = $a.ip_prefix
}
# surface only staging env IPs
if ($obj.Values -contains "$($Environment)")
{
$obj | ft -auto -HideTableHeaders
$Count += 1
}
}
Write-Host "CE Staging IPs count: [$Count]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment