GinShell.GoDaddy/Public/Remove-GsGoDaddyPointer.ps1
|
function Remove-GsGoDaddyPointer { <# .SYNOPSIS Deletes a DNS record (A or CNAME) via the GoDaddy API. .PARAMETER FullDomainName Fully qualified domain name (e.g., app.example.com). .PARAMETER Type DNS record type: A or CNAME. Default: CNAME. .EXAMPLE Remove-GsGoDaddyPointer -FullDomainName 'old.example.com' #> [CmdletBinding(SupportsShouldProcess)] param ( [Parameter(Mandatory)] [string]$FullDomainName, [ValidateSet('A', 'CNAME')] [string]$Type = 'CNAME' ) $dns = Resolve-GoDaddyDomain -FullDomainName $FullDomainName $headers = Get-GoDaddyHeaders $uri = "https://api.godaddy.com/v1/domains/$($dns.Domain)/records/$Type/$($dns.Name)" if (-not $PSCmdlet.ShouldProcess("$($dns.Name).$($dns.Domain)", "Delete $Type record")) { return } try { Invoke-RestMethod -Uri $uri -Headers $headers -Method DELETE -ErrorAction Stop Write-GsLog -Message "Deleted $($dns.Name).$($dns.Domain) ($Type)" -Type Success } catch { Write-GsLog -Message "Failed to delete record: $_" -Type Error } } |