Created
October 12, 2022 21:26
-
-
Save Cyb3r-Jak3/3dafb70dfa8647cb55227b1bddcd1ac7 to your computer and use it in GitHub Desktop.
Powershell script to set all Cloudflare Zones to full SSL
This file contains 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
$API_TOKEN = "<API Token with Zone:Zone:Read and Zone:Zone Settings:Edit>" | |
$baseUrl = "https://api.cloudflare.com/client/v4/zones" | |
$headers = @{ | |
'Authorization' = "Bearer $API_TOKEN" | |
'Content-Type' = "application/json" | |
} | |
$listUrl = $baseUrl + '?per_page=500' | |
$zones = Invoke-RestMethod -Uri $listUrl -Method 'GET' -Headers $headers | Select-Object -ExpandProperty result | |
foreach ($zones in $zones) { | |
Write-Host "Setting zone $($zones.name) to full SSL" | |
Write-Host "$($settings_ssl|ConvertTo-Json)" | |
$patchUrl = $baseUrl + '/' + $zones.id + '/settings/ssl' | |
$response = Invoke-RestMethod -Uri $patchUrl -Method 'PATCH' -Headers $headers -Body '{"value": "full"}' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment