Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps

Reply

Add Double Quotes Around Values When Creating TXT Records using API

New Member
Posts: 2
217     0
Hey

I'm working on a PowerShell script to create TXT records in Infoblox, using the API.
I having trouble getting the script to add double quotes around the values.

I want the value in the TXT record ($txtValue) to be define in Infoblox with double quotes, like this: "somerecord"

I've tried several methods to ensure the quotes are added, but nothing seems to work.
Could anyone suggest how to modify the script so that the double quotes are correctly included in the value?

Here's part of the script I'm using:

$csvPath = "C:\1.csv"
$dnsRecords = Import-Csv -Path $csvPath

foreach ($record in $dnsRecords) {
    $txtName = $record.Name
    $txtValue = $record.Value
    $body = "{"name":"$txtName","text":"$txtValue"}"

    try {
        $response = Invoke-WebRequest 'https://some-ip/wapi/v2.1/record:txt?_return_fields%2B=name,text&_return_as_object=1' -Method 'POST' -Headers $headers -Body $body
        Write-Host "TXT record" $txtName "," $txtValue " created successfully" -ForegroundColor Green
    } catch {
        Write-Host "Failed to create TXT record" $txtName $txtValue -ForegroundColor Red
    }
}

Thanks.

Re: Add Double Quotes Around Values When Creating TXT Records using API

New Member
Posts: 2
218     0

Adding thought..

Maybe there is not obligate to add " around TXT records?
Maybe infoblox add the " by itself?

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You