Last active
April 10, 2024 14:19
-
-
Save mardahl/4d6e71a2b41a962e53896902066b7893 to your computer and use it in GitHub Desktop.
CloudFlare powershell to bulk add new DNS Zones
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
#region declarations | |
$apikey = 'axxxxxxxxxxxxxxxxx6a4f5bxxxxxxxxxxxxx' | |
$email = '[email protected]' | |
$accountid = 'b6xxxxxxxxxxxxxxxxx8e57xxxx' | |
$domains = $(Get-Content .\domains.txt) #text file with 1 domain per line | |
#endregion declarations | |
#region execute | |
foreach ($domain in $domains){ | |
$headers = @{ | |
'X-Auth-Key' = $apikey | |
'X-Auth-Email' = $email | |
} | |
$settings = @{ | |
"name" = $domain.ToString() | |
"account" = $( | |
@{ | |
"id" = $accountid | |
} | |
) | |
"jump_start" = $false | |
"type" = "full" | |
} | |
$body = ConvertTo-Json -InputObject $settings | |
Write-Verbose "Adding $domain..." -Verbose | |
$createResponse = Invoke-RestMethod -Uri "https://api.cloudflare.com/client/v4/zones" -Method POST -Headers $headers -Body $body -ContentType "application/json" | |
$zoneID = $createResponse.result.id.ToString() | |
#scan for DNS records on current name server - comment the next line to disable this feature. This is a fix for the jump_start parameter not working. | |
$scanResponse = Invoke-RestMethod -Uri "https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records/scan" -Method POST -Headers $headers | |
Write-Verbose "Finished $domain" -Verbose | |
} | |
#endregion execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed cloudflare jump_start not working