Clear Domain Controller DNS cache

Discussion in 'Scripting' started by Jo Winchester, Jul 14, 2005.

  1. I need to find a way to automate clearing the DNS cache on 6 domain
    controllers. I found the following script on the MS scripting website - but
    when I try to run it it returns error: 0x8004100E - can anyone tell me why?
    I have tried running it directly on a domain controller, and also from a
    remote machine - but with no luck. Or does anyone have any other ideas how
    this could be automated?

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _

    Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Cache")

    For Each objItem in colItems
    Jo Winchester, Jul 14, 2005
    1. Advertisements

  2. I think I know what the problem is with this - the script need the DNS WMI
    service provider installed to run
    Jo Winchester, Jul 14, 2005
    1. Advertisements

  3. Jo Winchester

    Umesh Thakur Guest

    you can also use following code as an alternate:
    dim ws
    set ws=CreateObject("Wscript.Shell")
    ws.exec "%COMSPEC% /c ipconfig /flushdns"

    and put it in a loop...forever, include a sleep statement to suspend
    execution of the script for specified amount of interval...

    Umesh Thakur, Jul 15, 2005
  4. Thanks for your reply, but the cache that I am trying to clear is the cache
    that is held within DNS on the domain controller - not the local DNS cache on
    the server.
    Jo Winchester, Jul 15, 2005
  5. Jo Winchester

    Umesh Thakur Guest

    Umesh Thakur, Jul 15, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.