[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Commas are inserted in DNS TXT records where spaces should be - using vb script to create DNS records

Posted on 2007-08-08
8
Medium Priority
?
1,274 Views
Last Modified: 2008-01-09
I need to add SPF records for over a thousand domains in microsft DNS.
I wrote a vd script a while back that facilitates this for me for normal a records, etc.
I modified the script to loop through all our domains and a SPF record - it's really a TXT DNS record.

Here's the code:
set wshell = createobject("wscript.shell")
wshell.run "%comspec% /c C:\Windows\system32\dnscmd.exe localhost /RecordAdd " & domain & " @ TXT v=spf1 mx a:bbbmail.com ~all", 0, True
set wshell = nothing

This adds a record, but there are commas after the spaces in the string:
v=spf1, mx, a:bbbmailout2.com, ~all

It should look like:
v=spf1 mx a:bbbmailout2.com ~all

When I manually add a record, it works fine.

When I check the record, there are no commas but it displays with line breaks like so:
v=spf1
mx
a:bbbmailout2.com
~all

I'm not sure if the VB is inserting the commas or linebreaks or the DNS MMC is interpretting the line breaks with commas.

Any suggestions?
0
Comment
Question by:juliandormon
8 Comments
 
LVL 28

Expert Comment

by:peakpeak
ID: 19657764
The quotation marks after /Recordadd ...  instead.. make a string of the line from C:\Windows\system32\dnscmd.exe localhost /RecordAdd and to all and use it as:
wshell.run "%comspec% /c C:\Windows\system32\dnscmd.exe localhost /RecordAdd <string> ,0,True
0
 
LVL 17

Expert Comment

by:Tony Massa
ID: 19657767
Are all of these "SAME as PARENT" or are the node names different than the domain name?

-TM
0
 
LVL 17

Expert Comment

by:Tony Massa
ID: 19657783
I think the quotes are okay...but not sure that the @ symbol is valid in DNSCMD.
0
New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 19657818
You need quotes around the string you're trying to add.
The command as typed in a command window (always the first try if it doesn't work out in a script) would be:
dnscmd.exe localhost /RecordAdd some.domain.local " @ TXT "v=spf1 mx a:bbbmail.com ~all"
So in your VBScript, it would be (you can drop the cmd.exe btw., you can run exes by themselves):
wshell.run "dnscmd.exe localhost /RecordAdd " & domain & " @ TXT " & Chr(34) & "v=spf1 mx a:bbbmail.com ~all" & Chr(34), 0, True
0
 

Author Comment

by:juliandormon
ID: 19657874
Thanks oBdA that worked perfectly!
0
 
LVL 17

Expert Comment

by:Tony Massa
ID: 19657911
Nevermind about the @ symbol...I see the usage...

I think that all of the Text in the TXT record would have to be in quotes also since it's a string of text.  You have to use double quotes inside a quote to acheive that:

wshell.run ("%comspec% /c dnscmd.exe localhost /RecordAdd " & domain & " @ TXT ""v=spf1 mx a:testmail.com ~all"""), 0, True

-TM
0
 
LVL 17

Expert Comment

by:Tony Massa
ID: 19657916
man I'm slow...
0
 
LVL 28

Expert Comment

by:peakpeak
ID: 19658528
That's what I suggested
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question