This form does not yet contain any fields.
    Login
    « Be it known... | Main | An Identity Dilemna »
    Tuesday
    Jan292008

    I heart dnscmd

    "Hey Laura, I've got this list of 500 A records in our internal DNS that need to be deleted. I know it's a pain, but can you take care of it?"

    C:\LauraTools>for /f %h in (a.txt) do dnscmd <DNS Server Name> /RecordDelete <DNS Zone Name> %h A

    "Uh, sure boss, what do you need me to do with the other 8 hours and 59 minutes that I'm here today?"

    (As an aside, it is the simple genius of the "for-do" loop that leaves me under-motivated to adopt Powershell, as I'm hard-pressed to believe that there's a more elegant way out there to perform the above task.)

    Reader Comments (2)

    For your reference in PowerShell you would do it like this :

    $server = 'DNS Server Name'
    $zone = 'DNS Zone Name'

    get-content a.txt | foreach {dnscmd $server /RecordDelete "$zone $_ A"}

    # With use of aliases

    gc a.txt |% {dnscmd $server /RecordDelete "$zone $_ A"}

    Greetings /\/\o\/\/
    January 29, 2008 | Unregistered Commenter/\/\o\/\/
    Hey Nick, I've got this list of 500 A records in our internal DNS that need to be deleted. I know it's a pain, but can you take care of it?"

    C:\NickTools>for /f %h in (a.txt) do dnscmd <DNS Server Name> /RecordDelete <DNS Zone Name> %h A

    "Uh, sure boss, what do you need me to do with the other hour that I'm here today?"

    <surfs the Net>

    February 4, 2008 | Unregistered CommenterNick Gillott

    PostPost a New Comment

    Enter your information below to add a new comment.

    My response is on my own website »
    Author Email (optional):
    Author URL (optional):
    Post:
     
    All HTML will be escaped. Hyperlinks will be created for URLs automatically.