24 lines
1.1 KiB
PowerShell
24 lines
1.1 KiB
PowerShell
$email = 'tiago.ribeiro@inventcloud.com.br'
|
|
$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186'
|
|
$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' }
|
|
|
|
$zoneId = '62cb52dc520cf3be1a685099c1e3887d'
|
|
$recordName = 'mfe-shell-dev.invista.com.br'
|
|
|
|
# Buscar records existentes
|
|
$existing = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$recordName" -Headers $h
|
|
Write-Host "Records para $recordName`: $($existing.result.Count)"
|
|
$existing.result | ForEach-Object { Write-Host " $($_.id) $($_.type) -> $($_.content)" }
|
|
|
|
# Deletar o A record que criamos (136.248.66.216 = FortiGate)
|
|
foreach ($rec in $existing.result) {
|
|
if ($rec.content -eq '136.248.66.216') {
|
|
Write-Host "Deletando A record -> 136.248.66.216..."
|
|
$del = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$($rec.id)" `
|
|
-Method DELETE -Headers $h
|
|
Write-Host "Deleted: $($del.success)"
|
|
} else {
|
|
Write-Host "Mantendo record: $($_.type) -> $($rec.content)"
|
|
}
|
|
}
|
|
Write-Host "Concluido. mfe-shell-dev.invista.com.br revertido."
|