Servers

  • Does anyone have any script which loops through all servers and registers them on Enterprise Manager. Any help will be greatly appreciated

    TIA

  • TIA,

    I dont think it is a good idea to register sql servers through the script. You should register the servers manually because there are manual settings needed to do the registration.

    I dont have a script but would not recommend it anyway.

    Thanks

    taj

     


    Tajammal Butt

  • Well, thanks for our thoughts though. I have seen people using scripts with no problems while registering them in EM.specially if all servers have similar settings.

  • OK....if you get it please let me know. I would like to test it too.

    I have never seen or heard anyone using it.


    Tajammal Butt

  • You might try something like this, using VB script and SQL-DMO.

    - J. Kozloski, MCDBA


    ' script using SQL-DMO to find available servers on network

    ' and register them in Enterprise Manager

    ' this is a quick-and-dirty script. things like error-handling

    ' are left as an exercise to the reader.

    ' variable declarations

    Dim oSqlServer   ' SQLDMO SQLServer object

    Dim oApplication  ' SQLDMO Application object

    Dim oGroup    ' SQLDMO ServerGroup object

    Dim strGroupName  ' string containing name of group to add servers to

    Dim i     ' counter

    Dim nameList   ' SQLDMO NameList object

    ' This can be changed, of course

    strGroupName = "AutoRegisteredServers"

    Sub CreateGroup(strNewGroupName)

    Dim oNewGroup

     set oNewGroup = CreateObject("SQLDMO.ServerGroup")

     oNewGroup.Name = strNewGroupName

     oApplication.ServerGroups.Add(oNewGroup)

     

     set oNewGroup = Nothing

    End Sub

    Sub RegisterServer(strServerName)

    Dim oRegServer

     Wscript.Echo "Registering " & strServerName

     

     ' Create a new registered server object

     Set oRegServer = CreateObject("SQLDMO.RegisteredServer")

     

     With oRegServer

      .Name = strServerName

      .UseTrustedConnection = 1

      ' .Login = "username"

      ' .Password = "password"

     End With

     

     oGroup.RegisteredServers.Add(oRegServer)

     

     Set oRegServer = Nothing

    End Sub

    ' Create a new SQLServer object and obtain its Application object

    Set oSqlServer = CreateObject("SQLDMO.SQLServer")

    Set oApplication = oSqlServer.Application

    ' Create a new SQL Server Group in EM

    CreateGroup(strGroupName)

    ' Get the servergroup we just created

    Set oGroup = oApplication.ServerGroups(strGroupName)

    ' Get a list of available SQL Servers on the network

    Set nameList = oApplication.ListAvailableSQLServers()

    ' Loop through the NameList object and register each server name

    For i = 1 to nameList.Count

     RegisterServer(nameList(i))

    Next

    -- J.Kozloski, MCDBA, MCITP

  • Copy the registry contents from the old pc to the new pc from this location:

    HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\80\Tools\SQLEW\Registered Servers X

    restore to the same location using any registry copy. I use this few times, every time I had to install sql tools for developers.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply