Announcement

Collapse
No announcement yet.

Remote DNS modifications

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

  • Remote DNS modifications

    Is there any way to modify static DNS entries remotely on Win2K servers?

  • #2
    Re: Remote DNS modifications

    Not with Hyena, but I will forward this to Development to see if there are any options in this area for future changes.

    Comment


    • #3
      Re: Remote DNS modifications

      Thanks for taking this into consideration.

      To have the Network Tab of the Computer Properties editable would be a boon to remote administration of 2K machines.

      Comment


      • #4
        Re: Remote DNS modifications

        A scripting solution, similar to this, may be a solution. WMI might be able to do what you want, but I haven't found anything to "PUT" the information, only gather it.
        http://www.serverwatch.com/tutorials...le.php/1476991

        Comment


        • #5
          Re: Remote DNS modifications

          Thanks for the info, The Supply Guy, but I am looking for something that cannot be viewed or interrupted by the end user.

          Comment


          • #6
            Re: Remote DNS modifications

            Yesyesyesyes, I need this capability. We're changing DNS servers and suffixes as part of our AD migration. Right now, we're stuggling with scripts.

            Comment


            • #7
              Re: Remote DNS modifications

              You may be able to do this with netsh - check it out.

              Comment


              • #8
                Re: Remote DNS modifications

                Not sure if this is the solution you're looking for...
                http://www.free2code.net/code/vb/6/code_164.php

                ...hope it helps!

                Joel

                Comment


                • #9
                  Re: Remote DNS modifications

                  This might actually work. I'll test it out next week and post the results.

                  Comment


                  • #10
                    Re: Remote DNS modifications

                    With a little tweaking, it does exactly what I want...Modified code below (removed the auto-reboot since this is not what I want it to do.). I will also be removing the action prompts so it can run unattended. I don't think I can create a custom tool, since the servername(s) are specified in the code, not as a switch, but I will look into it. If anyone else can fix this, please post here.

                    For original code, use link above.
                    ___________________________________________
                    ' IMPORTANT !!!! Change these constants !!!!
                    Const STR_SERVERS = "ServerA ServerB" ' Enter your servers here, separated by a space
                    Const STR_NEWDNS1 = "192.168.0.1"
                    Const STR_NEWDNS2 = "192.168.0.2"
                    Const STR_NEWWINS1= "192.168.0.1"
                    Const STR_NEWWINS2= "192.168.0.2"

                    ' ///////////////////////////////////////////////////////////////////////////////////////////////
                    Do
                    cKeuze = MakeChoise( "Choose: Report or Change (R/C)?" )
                    Loop until cKeuze = "C" Or cKeuze = "R"
                    WScript.Echo
                    If( cKeuze = "C" ) Then
                    Change( STR_SERVERS )
                    Else
                    Report( STR_SERVERS )
                    End If
                    WScript.Echo( "Check out http://www.activxperts.com for more samples and components" )
                    ' ///////////////////////////////////////////////////////////////////////////////////////////////


                    ' ///////////////////////////////////////////////////////////////////////////////////////////////
                    Sub Change( strParamServers )
                    arrServers = Split( strParamServers, " " )
                    For i = 0 To UBound( arrServers )
                    ShowDnsWins arrServers( i )
                    Do
                    cKeuze = MakeChoise( " Change DNS/WINS (y/n)?" )
                    Loop until cKeuze = "Y" Or cKeuze = "N"
                    If( cKeuze = "Y" ) Then
                    SetDnsWins arrServers( i )
                    End If

                    WScript.StdOut.Write( vbCrlf )
                    Next
                    End Sub
                    ' ///////////////////////////////////////////////////////////////////////////////////////////////
                    Sub Report( strParamServers )
                    arrServers = Split( strParamServers, " " )
                    For i = 0 To UBound( arrServers )
                    ShowDnsWins arrServers( i )
                    Next
                    End Sub
                    ' ///////////////////////////////////////////////////////////////////////////////////////////////
                    Sub ShowDnsWins( strServer )
                    strWinMgmt = "winmgmts:{impersonationLevel=impersonate}!//"& strServer &""
                    Set objNICs = GetObject( strWinMgmt ).InstancesOf( "Win32_NetworkAdapterConfiguration" )
                    WScript.StdOut.Write( strServer & ": " & vbCrlf )
                    For Each objNIC In objNICs
                    If objNIC.IPEnabled Then
                    WScript.StdOut.Write( " " & objNIC.Description & ": " & vbCrlf & " " )
                    n = 1
                    For Each strDns In objNIC.DNSServerSearchOrder
                    WScript.StdOut.Write "DNS" & n & ":" & strDns & " "
                    n = n + 1
                    Next
                    WScript.StdOut.Write( vbCrlf )
                    End If
                    Next
                    WScript.StdOut.Write( vbCrlf )
                    End Sub
                    ' ///////////////////////////////////////////////////////////////////////////////////////////////
                    Sub SetDnsWins( strServer )
                    strWinMgmt = "winmgmts:{impersonationLevel=impersonate}!//"& strServer &""
                    Set objNICs = GetObject( strWinMgmt ).InstancesOf( "Win32_NetworkAdapterConfiguration" )

                    WScript.StdOut.Write( " Set DNS for NIC: " )
                    For Each objNIC In objNICs
                    If objNIC.IPEnabled Then
                    objNIC.SetWINSServer STR_NEWWINS1,STR_NEWWINS2
                    objNIC.SetDNSServerSearchOrder Array(STR_NEWDNS1,STR_NEWDNS2)
                    WScript.StdOut.Write objNIC.Description & " "
                    End If
                    Next
                    WScript.StdOut.Write( vbCrlf )
                    End Sub
                    ' ///////////////////////////////////////////////////////////////////////////////////////////////
                    Function MakeChoise( strMesg )
                    WScript.StdOut.Write(strMesg)
                    WScript.StdIn.Read(0)
                    strChoise = WScript.StdIn.ReadLine()
                    MakeChoise = UCase( Left( strChoise, 1 ) )
                    End Function
                    ____________________________________________

                    Comment


                    • #11
                      Re: Remote DNS modifications

                      There's a few ways to do this, but my guess would be you'd like to set up a tool in Hyena, then right-click on a machine, and select the tool. Correct??

                      Provide me with your ideal scenario, and I'll script it for ya!

                      Joel

                      Comment


                      • #12
                        Re: Remote DNS modifications

                        I see using this to modify static settings on a group of computers, so ideally, it would have to be able to accomodate multiple name selections (Selecting SERVERS in the left pane, and selecting all servers in the right pane and executing the command).

                        This would not be used often, but if you have a DNS servers IP or preference change, then all of your static entries could be changed almost as easily as your DHCP scopes.

                        Comment


                        • #13
                          Re: Remote DNS modifications

                          Ideal situation:
                          New WINS infrastructure being put into place. Instead of using SMS or other tools to deploy a WINS script, I'd like to select a group of servers in Hyena, right click and activate the WINS changing script.

                          Comment


                          • #14
                            Re: Remote DNS modifications

                            Lemme know if this does the trick:

                            Click on Servers (or Computers) in the left pane, then select the systems you wish to run this tool on (max is 20, don't forget).

                            '***** script starts here ***********
                            Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
                            Dim WshNetwork : Set WshNetwork = WScript.CreateObject("WScript.Network")
                            Dim objArgs : Set objArgs = WScript.Arguments ' create object with collection

                            If objArgs.Count >= 1 Then
                            strTargetComp = objArgs(0) ' assign the passed computer name to a variable
                            Else
                            strResponse = MsgBox ("Do you wish to run this script on the local machine?", vbYesNo + vbQuestion + vbDefaultButton2, "Run this on the local machine?")
                            If strResponse = vbNo Then
                            WScript.Quit
                            Else
                            strTargetComp = WshNetwork.ComputerName
                            End If
                            End If

                            ' IMPORTANT !!!! Change these constants !!!!
                            Const STR_NEWDNS1 = "192.168.0.1"
                            Const STR_NEWDNS2 = "192.168.0.2"
                            Const STR_NEWWINS1= "192.168.0.1"
                            Const STR_NEWWINS2= "192.168.0.2"

                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Do
                            cKeuze = MakeChoise( "Choose: Report or Change (R/C)?" )
                            Loop until cKeuze = "C" Or cKeuze = "R"

                            If( cKeuze = "C" ) Then
                            Change
                            Else
                            Report
                            End If
                            ' ///////////////////////////////////////////////////////////////////////////////////////////////


                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Sub Change
                            ShowDnsWins strTargetComp
                            Do
                            cKeuze = MakeChoise( " Change DNS/WINS (y/n)?" )
                            Loop until cKeuze = "Y" Or cKeuze = "N"
                            If( cKeuze = "Y" ) Then
                            SetDnsWins strTargetComp
                            'RebootServer strTargetComp ' remove the mark to reboot
                            End If
                            End Sub

                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Sub Report
                            ShowDnsWins
                            End Sub

                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Sub ShowDnsWins
                            On Error Resume Next ' needed in case an adapter has no DNS settings
                            strWinMgmt = "winmgmts:{impersonationLevel=impersonate}!//"& strTargetComp &""
                            Set objNICs = GetObject( strWinMgmt ).InstancesOf( "Win32_NetworkAdapterConfiguration where IPEnabled=TRUE" )
                            WScript.StdOut.Write( strTargetComp & ": " & vbCrlf )
                            For Each objNIC In objNICs
                            If objNIC.IPEnabled Then
                            WScript.StdOut.Write( " " & objNIC.Description & ": " & vbCrlf & " " )
                            n = 1
                            For Each strDns In objNIC.DNSServerSearchOrder
                            WScript.StdOut.Write "DNS" & n & " : " & strDns & vbCrLf
                            n = n + 1
                            Next
                            WScript.StdOut.Write( vbCrlf )
                            End If
                            Next
                            WScript.StdOut.Write( vbCrlf )
                            On Error Goto 0
                            End Sub
                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Sub SetDnsWins
                            strWinMgmt = "winmgmts:{impersonationLevel=impersonate}!//" & strTargetComp
                            Set objNICs = GetObject( strWinMgmt ).InstancesOf( "Win32_NetworkAdapterConfiguration" )

                            WScript.StdOut.Write( " Set DNS for NIC: " )
                            For Each objNIC In objNICs
                            If objNIC.IPEnabled Then
                            objNIC.SetWINSServer STR_NEWWINS1,STR_NEWWINS2
                            objNIC.SetDNSServerSearchOrder Array(STR_NEWDNS1,STR_NEWDNS2)
                            WScript.StdOut.Write objNIC.Description & " "
                            End If
                            Next
                            WScript.StdOut.Write( vbCrlf )
                            End Sub
                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Function MakeChoise( strMesg )
                            WScript.StdOut.Write(strMesg)
                            WScript.StdIn.Read(0)
                            strChoise = WScript.StdIn.ReadLine()
                            MakeChoise = UCase( Left( strChoise, 1 ) )
                            End Function
                            ' ///////////////////////////////////////////////////////////////////////////////////////////////
                            Sub RebootServer( strServer )
                            Set OpSysSet = GetObject("winmgmts:{(RemoteShutdown)}//" & strTargetComp & "/root/cimv2").ExecQuery("Select * from Win32_OperatingSystem where Primary=True")
                            WScript.StdOut.Write( " Reboot: " )
                            For Each OpSys In OpSysSet
                            WScript.StdOut.Write OpSys.Name
                            OpSys.Reboot()
                            Next
                            WScript.StdOut.Write( vbCrlf )
                            End Sub
                            '******** script ends here *******

                            I put the reboot sub back in, but REM'd it out in the main portion, just in case.

                            Comment


                            • #15
                              Re: Remote DNS modifications

                              I'm knew to Hyena so please don't blast me but what would be the command line I would use to add this as a custom tool. I've read the documentation but I'm stupid and unsure how to do it. Thanks.

                              Comment

                              Working...
                              X