Sunday, February 19, 2012

Distributing a Custom SQL Server Enterprise Manager MMC with Server Registrations

Is it possible to make available to several administrators a custom
SQL Server Enterprise Manager MMC containing 80 server registrations?
I would like to avoid having to manually recreate the console on
multiple machines. I tried distributing the .MSC file and exporting
and importing the following registry key, but only the group names
appeared in the MMC, not the servers:
& #91;HKEY_CURRENT_USER\Software\Microsoft
\Microsoft SQL
Server\80\Tools\SQLEW\Registered Servers X]
Any suggestions?
Thanks,
EricIt used to work! Check here for some vb and Java scripts:
http://groups.google.com.au/groups?...eadm=PqyaNXwaEH
A.2900%40cpmsftngxa06.phx.gbl&rnum=4&prev=/groups%3Fq%3Denterprise%2Bman
ager%2Bregistry%2Bsql%2Bimport%26hl%3Den
%26lr%3D%26ie%3DUTF-8
HTH,
g.
http://www.sqlskunkworks.com
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!|||Thanks for the reply! At your suggestion, I found the following message
which contained an effective solution:
From: "Mingqing Cheng [MSFT]" (v-mingqc@.online.microsoft.com)
Subject: RE: Export/Import SQL EM Registrations?
View: Complete Thread (6 articles)
Original Format
Newsgroups: microsoft.public.sqlserver.tools
Date: 2004-07-16 00:25:54 PST
Hi TIA,
From your descriptions, I understood that you would like to export all
registered Server and then import them in a new machine. Have I
understood
you? If there is anything I misunderstood, please feel free to let me
know
Based on my scope, The method by exporting Register Files is not
supported
from SQL7 SP3 as encryption has been put in the process. Furtuantely, we
could do it by creating SQL-DMO
Here are the steps:
1. Create a vbs file and call it readreg.vbs which contains the
following.
Please substitute [servername] with SQL Server name and [password] w
ith
the
SA password.
It also creates a table RegServers in pubs database so make sure that
this
does not exist. This script collects information about the currently
registered servers and stores the information in the RegServers table.
Dim oApplication
Dim oServerGroups
Dim oServerGroup
Dim oRegisteredServer
Dim oNewRegisteredServer
Dim oSQLServer
Dim MsgOutput
set oSQLServer = CreateObject("SQLDMO.SQLServer")
Set oApplication = CreateObject("SQLDMO.Application")
Set oServerGroups = oApplication.ServerGroups
oSQLServer.Connect "servername", "sa", "password"
oSQLServer.ExecuteImmediate "Create table pubs..RegServers(ServerName
varchar(30),
SLogin varchar(30), SPassword varchar(30), IsNtAuth varchar(2))"
For Each oServerGroup in oApplication.ServerGroups
For Each oRegisteredServer in oServerGroup.RegisteredServers
MsgOutput = "Insert Into Pubs..RegServers values("
MsgOutput = MsgOutput + "'" + oRegisteredServer.Name + "', '" +
oRegisteredServer.Login + "', '" + oRegisteredServer.Password + "', '" +
CStr(oRegisteredServer.UseTrustedConnection) + "')"
oSQLServer.ExecuteImmediate MsgOutput
Next
Next
oSQLServer.Disconnect
msgbox "complete"
2. To run, open a command-prompt and run "cscript readreg.vbs".
3. To verify that the information was retrieved correctly, go to the
SQL
Server
specified in the script and run the following:
use pubs
select * from RegServers
4. Create another vbs file and call it createreg.vbs which contains the
following:
Again substitute [servername] with SQL Server name and [password] wi
th
the
sa
password.
Dim oApplication
Dim oServerGroups
Dim oServerGroup
Dim oRegisteredServer
Dim oNewRegisteredServer
Dim oSQLServer
Dim oQueryResults
Dim MsgOutput
Dim num
Dim SrvNameOutput
Dim LoginOutput
Dim PassOutput
Dim AuthOutput
Dim GetLoginOutput
set oSQLServer = CreateObject("SQLDMO.SQLServer")
Set oApplication = CreateObject("SQLDMO.Application")
Set oServerGroups = oApplication.ServerGroups
oSQLServer.Connect "servername" , "sa", "password"
set oQueryResults = oSQLServer.ExecuteWithResults ("Select ServerName,
SLogin,
SPassword, IsNtAuth from pubs..RegServers")
For num = 1 To oQueryResults.Rows
SrvNameOutput = oQueryResults.GetColumnString(num, 1)
LoginOutput = oQueryResults.GetColumnString(num, 2)
PassOutput = oQueryResults.GetColumnString(num, 3)
AuthOutput = oQueryResults.GetColumnString(num, 4)
If LoginOutput = "" Then
LoginOutput = " "
End if
Set oNewRegisteredServer = CreateObject("SQLDMO.RegisteredServer")
oNewRegisteredServer.Login = LoginOutput
oNewRegisteredServer.Name = SrvNameOutput
oNewRegisteredServer.Password = PassOutput
oNewRegisteredServer.UseTrustedConnection = CLng(AuthOutput)
oServerGroups("SQL Server
Group").RegisteredServers.Add(oNewRegisteredServer)
Next
Msgbox "complete"
5. To run, open a command-prompt and run "cscript createreg.vbs".
NOTE:
a. When doing the tests, please make sure that Enterprise Manager is
closed.
b. The script gathers information about the registered servers for the
currently
logged on user.
c. If you want to test on a single machine, you may do the following:
- run readreg.vbs
- Delete the registration from Enterprise Manager or delete the entries
in
the
following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Mic
rosoft SQL
Server\80\Tools\SQLEW\Registered
Servers X
Please test the method and I strongly recommand you doing this in a
development machine first
Thank you for your patience and cooperation. If you have any questions
or
concerns, don't hesitate to let me know. We are here to be of
assistance!
Sincerely yours,
Mingqing Cheng
Microsoft Developer Community Support
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment