Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Add Double Quotes Around Values When Creating TXT Records using API
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
211     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
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
212     0
Adding thought..
Maybe there is not obligate to add " around TXT records?
Maybe infoblox add the " by itself?