Public/Curanet/DNS/Update-CuraDNSRecord.ps1

function Update-CuraDNSRecord {
    <#
        .SYNOPSIS
            Command to update an existing record.
         
        .PARAMETER DomainName
            String containing domainname
 
        .PARAMETER ID
            Integer containing the ID of the record needed to be changed.
         
        .PARAMETER Value
            String containing the new value
         
        .OUTPUTS
            $true on success, $false on error
    #>


    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [string]
        $DomainName,

        [Parameter(Mandatory=$true)]
        [int]
        $ID,

        [Parameter(Mandatory=$true)]
        [string]
        $Value
    )

    $Existing = Get-CuraDNSRecords -DomainName $DomainName | Where-Object id -eq $ID

    if ( $Existing ) {

        $Body = @{
            name        = $Existing.Name
            type        = $Existing.Type
            ttl         = $Existing.TTL
            priority    = $Existing.Priority
            data        = $Value
        }
    
        $result = Invoke-CuraDNSRequest -Uri "Domains/$($DomainName)/Records/$($ID)" -Method "PUT" -Payload ($Body | ConvertTo-Json)

        if($result) {
            return $true
        }

        else {
            return $false
        }
    }

    return $false
}