Announcement

Collapse
No announcement yet.

Change TCP/IP advance settings via script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change TCP/IP advance settings via script

    Hi,
    I need to Change the TCP/IP advance settings via script
    I need somehow to check the "Use this connection's DNS suffix in DNS registration"

    VBS or Powershell scripts will be nice

    Thanks!
    Attached Files

  • #2
    Re: Change TCP/IP advance settings via script

    This has come up here a couple of times recently -- use the search facility for variations on TCP/IP Script and you will get general instructions
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Change TCP/IP advance settings via script

      Originally posted by Ossian View Post
      This has come up here a couple of times recently -- use the search facility for variations on TCP/IP Script and you will get general instructions
      sorry but I did, and didn't find anything that can hint for the solution

      Comment


      • #4
        Re: Change TCP/IP advance settings via script

        http://forums.petri.com/showthread.php?t=13280 gives a hint...

        So does the fifth post in this thread http://www.tomshardware.co.uk/forum/...8221_35_0.html

        Google has lots of suggestions.
        Gareth Howells

        BSc (Hons), MBCS, MCP, MCDST, ICCE

        Any advice is given in good faith and without warranty.

        Please give reputation points if somebody has helped you.

        "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

        "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

        Comment


        • #5
          Re: Change TCP/IP advance settings via script

          Try this:

          Code:
          On Error Resume Next
          
          strComputer = "."
          
          Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
             & strComputer & "\root\cimv2") 
           
          ' take out the AND DHCPEnabled='TRUE' if your running this on servers with static ip's
          Set colNetAdapters = objWMIService.ExecQuery( _
             "Select * from Win32_NetworkAdapterConfiguration where IPEnabled='TRUE' AND DHCPEnabled='TRUE'")
          
             For Each objNetAdapter In colNetAdapters
                  strDomainDNSRegistrationEnabled = objNetAdapter.DomainDNSRegistrationEnabled
                     If strDomainDNSRegistrationEnabled = -1 Then
                        msgbox "DNS Suffix Registration is already enabled!"
                     Else
          	      intRegister = objNetAdapter.SetDynamicDNSRegistration (True, True)
          	      msgbox "DNS Suffix Registration is now enabled!"
                     End If
             Next
          
          WScript.quit(0)
          Last edited by ekrengel; 11th August 2009, 16:56.

          Comment


          • #6
            Re: Change TCP/IP advance settings via script

            Originally posted by ekrengel View Post
            Try this:

            Code:
            On Error Resume Next
            
            strComputer = "."
            
            Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
               & strComputer & "\root\cimv2") 
             
            ' take out the AND DHCPEnabled='TRUE' if your running this on servers with static ip's
            Set colNetAdapters = objWMIService.ExecQuery( _
               "Select * from Win32_NetworkAdapterConfiguration where IPEnabled='TRUE' AND DHCPEnabled='TRUE'")
            
               For Each objNetAdapter In colNetAdapters
                    strDomainDNSRegistrationEnabled = objNetAdapter.DomainDNSRegistrationEnabled
                       If strDomainDNSRegistrationEnabled = -1 Then
                          msgbox "DNS Suffix Registration is already enabled!"
                       Else
            	      intRegister = objNetAdapter.SetDynamicDNSRegistration (True, True)
            	      msgbox "DNS Suffix Registration is now enabled!"
                       End If
               Next
            
            WScript.quit(0)
            That will change the "Use this connection's DNS suffix in DNS registration" nicely

            One note though,
            unlike String type values 'Boolean data type' does not require to be between quotes (see WQL in the sample below).
            Code:
            ' http://msdn.microsoft.com/en-us/libr...98(VS.85).aspx
            
            Const FullDNSRegistrationEnabled = True
            Const DomainDNSRegistrationEnabled = True '("Use this connection's DNS suffix in DNS registration" default = False)
            
            strComputer = "."
            
            Set objWMIService = GetObject("winmgmts:" _
               & "{impersonationLevel=impersonate}!\\" _
               & strComputer & "\root\cimv2") 
            
            Set colNetCards = objWMIService.ExecQuery (_
               "Select * From Win32_NetworkAdapterConfiguration " _
               & "Where IPEnabled = True ")
            
            For Each objNetCard in colNetCards
               objNetCard.SetDynamicDNSRegistration _
                      FullDNSRegistrationEnabled, DomainDNSRegistrationEnabled
            Next
            \Rems

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment


            • #7
              Re: Change TCP/IP advance settings via script

              Many thanks to all of you!!!

              Comment

              Working...
              X