GinShell.GoDaddy/Public/Remove-GsGoDaddyPointer.ps1
|
function Remove-GsGoDaddyPointer { [CmdletBinding(SupportsShouldProcess)] param ( [Parameter(Mandatory)] [string]$FullDomainName, [Parameter(Mandatory = $false)] [ValidateSet("A", "CNAME")] [string]$Type = 'CNAME' ) $dns = $FullDomainName.Split('.') $len = $dns.Length $name = ($dns[0..($len - 3)] -join '.') $domain = "$($dns[-2]).$($dns[-1])" $creds = Get-GoDaddyCreds $headers = @{ Authorization = "sso-key $($creds.Key):$($creds.Secret)" } $uri = "https://api.godaddy.com/v1/domains/$domain/records/$Type/$name" if ($PSCmdlet.ShouldProcess("$name.$domain", "Delete $Type record")) { try { Invoke-RestMethod -Uri $uri -Headers $headers -Method DELETE -ErrorAction Stop Write-GsLog -Message "Deleted $name.$domain ($Type)" -Type Success } catch { Write-GsLog -Message "Failed to delete record: $_" -Type Error } } } |