Public/Curanet/New-CuraDNSRecord.ps1
function New-CuraDNSRecord { <# .SYNOPSIS Command to create a new DNS record .PARAMETER DomainName String containing domainname .PARAMETER Hostname (Optional, default empty) String containing hostname of the DNS record - Should not include the domainname .PARAMETER Type String containing the type of the DNS record. .PARAMETER TTL (Optional, default 3600) Integer containing the Time To Live value. .PARAMETER Priority (Optional, default 0) Integer containing the Priority value. .PARAMETER Value String containing the value of the record. .OUTPUTS Object containing the DNS record OR error. .EXAMPLE $domain = "example.com" $hostname = "www" $type = "A" $value = "11.22.33.44" New-CuraDNSRecord -DomainName $domain -Hostname $hostname -Type $type -Value $value This example creates a new A record for "www.example.com". .EXAMPLE New-CuraDNSRecord -DomainName "test.com" -Type "MX" -Value "mail.test.com" This example creates a new MX record for "test.com". #> [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string] $DomainName, [Parameter()] [string] $Hostname, [Parameter(Mandatory=$true)] [string] $Type, [Parameter()] [int] $TTL = 3600, [Parameter()] [int] $Priority = 0, [Parameter(Mandatory=$true)] [string] $Value ) if( $Hostname -ne '') { $Name = "$($Hostname).$($DomainName)" } else { $Name = $DomainName } $Body = @{ name = $Name type = $Type.ToUpper() ttl = $TTL priority = $Priority data = $Value } $result = Invoke-CuraDNSRequest -Uri "Domains/$($DomainName)/Records" -Method "POST" -Payload ($Body | ConvertTo-Json) if($result.Content) { return $result.Content } return $result } |