-
Notifications
You must be signed in to change notification settings - Fork 1
/
godaddy-dns.ps1
37 lines (30 loc) · 1.18 KB
/
godaddy-dns.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$goDaddyApi="<APIKEY>"
$goDaddySecret="<APISECRET>"
$hpIloHost = "<ILO HOST>"
$dnsChallenge = "<REPLACE DNS CHALLENGE FROM CERTBOT>"
$domainSegments = $hpIloHost.Split('.')
$domainSecondPart = "$($domainSegments[$domainSegments.Length-2]).$($domainSegments[$domainSegments.Length-1])"
$domainFirstPart = "";
for ($i=0; $i -lt $domainSegments.Length-2; $i++){
$domainFirstPart += $domainSegments[$i];
if ($i -ne $domainSegments.Length-3){
$domainFirstPart+="."
}
}
$goDaddyDnsBody=@(
@{
"data"= $dnsChallenge;
"port"= 1;
"priority"= 0;
"ttl"= 600;
"weight"= 0
}
)
Write-Host "Calling GoDaddy!"
#Write-Host "Calling https://api.godaddy.com/v1/domains/$domainSecondPart/records/TXT/_acme-challenge.$domainFirstPart"
Write-Host ($goDaddyDnsBody |ConvertTo-Json -AsArray)
Invoke-RestMethod -Method Put -Uri "https://api.godaddy.com/v1/domains/$domainSecondPart/records/TXT/_acme-challenge.$domainFirstPart" `
-Headers @{"Authorization"= "sso-key $($goDaddyApi):$goDaddySecret"} `
-ContentType "application/json" `
-Body ($goDaddyDnsBody | ConvertTo-Json -AsArray)
Write-Host "Success!"