Created
May 18, 2016 09:38
-
-
Save Sam-Martin/ca7fc4cb8ba696ccc9978dda7d7cd4b5 to your computer and use it in GitHub Desktop.
Update all your pingdom checks to use a single ID
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
$VerbosePreference = "Continue" | |
if(!$cred){ | |
$cred = Get-Credential | |
} | |
$IntegrationID = 707 | |
if($(Read-Host "Warning, this will replace all checks' integrations with ONLY integration ID $integrationID, do you wish to continue? y/n") -ne 'y'){ | |
return; | |
} | |
$params = @{ | |
uri = "https://api.pingdom.com/api/2.0/checks" | |
method = "get" | |
headers = @{ | |
"App-Key" = "" | |
# Important, this is not YOUR Pingdom login, this is the original ACCOUNT email address | |
"Account-Email" = "" | |
"Accept-Encoding" = "gzip" | |
} | |
credential = $cred | |
ErrorAction = "Stop" | |
Verbose = $true | |
} | |
try{ | |
$checks = Invoke-RestMethod @params | |
$checks = $checks.checks | ?{$_.status -ne "paused"} | |
}catch{ | |
Write-Error $_.exception.message | |
} | |
$detailedChecks = @{} | |
foreach($check in $checks){ | |
# Get detailed info about the check | |
$params.uri = 'https://api.pingdom.com/api/2.0/checks/' + $check.id | |
$check = Invoke-RestMethod @params | |
if(!$check.check.integrationids){ | |
$updateParams = $params.clone() | |
$updateParams.method = "put" | |
$updateParams.add("body", @{"integrationids"=$integrationID}) | |
Invoke-RestMethod @updateParams | Out-Null | |
Write-Verbose "updated $($check.check.name) to use integration" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment