|
|
|
|
||||||
| ms.sqlserver.setup Questions about SQL Server. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
The following code works ...
Set objWMIService = GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement") Set colItems = objWMIService.ExecQuery("SELECT * FROM ServerNetworkProtocolProperty WHERE PropertyName = 'TcpPort'",,48) For Each objItem in colItems objItem.SetStringValue("1433") Next However is a specifiy a named instance like Set objWMIService = GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement\Instance_Name") I always get back a null object. How do I specify a named instance of SQL ? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Mar 2, 6:35 pm, "Michael Tissington" <mtissing...@newsgroup.nospam>
wrote: > The following code works ... > > Set objWMIService = > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement") > Set colItems = objWMIService.ExecQuery("SELECT * FROM > ServerNetworkProtocolProperty WHERE PropertyName = 'TcpPort'",,48) > For Each objItem in colItems > objItem.SetStringValue("1433") > Next > > However is a specifiy a named instance like > > Set objWMIService = > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement\Instance_Name") > > I always get back a null object. > > How do I specify a named instance of SQL ? WMI "SQL Server" InstanceName root\Microsoft\SqlServer \ComputerManagement You will get plenty of doe samples |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Hmm, I'm not seeing anything that relates to specifying an InstanceName with
SqlServer\ComputerManagement "Steve" <morriszone@hotmail.com> wrote in message news:1172899395.780295.14950@t69g2000cwt.googlegro ups.com... On Mar 2, 6:35 pm, "Michael Tissington" <mtissing...@newsgroup.nospam> wrote: > The following code works ... > > Set objWMIService = > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement") > Set colItems = objWMIService.ExecQuery("SELECT * FROM > ServerNetworkProtocolProperty WHERE PropertyName = 'TcpPort'",,48) > For Each objItem in colItems > objItem.SetStringValue("1433") > Next > > However is a specifiy a named instance like > > Set objWMIService = > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement\Instance_Name") > > I always get back a null object. > > How do I specify a named instance of SQL ? WMI "SQL Server" InstanceName root\Microsoft\SqlServer \ComputerManagement You will get plenty of doe samples |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Mar 2, 10:23 pm, "Michael Tissington"
<mtissing...@newsgroup.nospam> wrote: > Hmm, I'm not seeing anything that relates to specifying an InstanceName with > SqlServer\ComputerManagement > > "Steve" <morrisz...@hotmail.com> wrote in message > > news:1172899395.780295.14950@t69g2000cwt.googlegro ups.com... > On Mar 2, 6:35 pm, "Michael Tissington" <mtissing...@newsgroup.nospam> > wrote: > > > > > > > The following code works ... > > > Set objWMIService = > > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement") > > Set colItems = objWMIService.ExecQuery("SELECT * FROM > > ServerNetworkProtocolProperty WHERE PropertyName = 'TcpPort'",,48) > > For Each objItem in colItems > > objItem.SetStringValue("1433") > > Next > > > However is a specifiy a named instance like > > > Set objWMIService = > > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement\Instance_Name") > > > I always get back a null object. > > > How do I specify a named instance of SQL ? > > WMI "SQL Server" InstanceName root\Microsoft\SqlServer > \ComputerManagement > > You will get plenty of doe samples- Hide quoted text - > > - Show quoted text - ' enum protocols and show status set wmi = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer \ComputerManagement") for each prop in wmi.ExecQuery("select * " & _ "from ServerNetworkProtocol " & _ "where InstanceName = 'mssqlserver'") WScript.Echo prop.ProtocolName & " - " & _ prop.ProtocolDisplayName & " " & _ prop.Enabled next ' enable named pipes for each changeprop in wmi.ExecQuery("select * " & _ "from ServerNetworkProtocol " & _ "where InstanceName = 'mssqlserver' and " & _ "ProtocolName = 'Np'") changeprop.SetEnable() next |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Mar 3, 8:28 am, "Steve" <morrisz...@hotmail.com> wrote:
> On Mar 2, 10:23 pm, "Michael Tissington" > > > > > > <mtissing...@newsgroup.nospam> wrote: > > Hmm, I'm not seeing anything that relates to specifying an InstanceNamewith > > SqlServer\ComputerManagement > > > "Steve" <morrisz...@hotmail.com> wrote in message > > >news:1172899395.780295.14950@t69g2000cwt.googlegr oups.com... > > On Mar 2, 6:35 pm, "Michael Tissington" <mtissing...@newsgroup.nospam> > > wrote: > > > > The following code works ... > > > > Set objWMIService = > > > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement") > > > Set colItems = objWMIService.ExecQuery("SELECT * FROM > > > ServerNetworkProtocolProperty WHERE PropertyName = 'TcpPort'",,48) > > > For Each objItem in colItems > > > objItem.SetStringValue("1433") > > > Next > > > > However is a specifiy a named instance like > > > > Set objWMIService = > > > GetObject("winmgmts:\\.\root\Microsoft\SqlServer\C omputerManagement\Instance_Name") > > > > I always get back a null object. > > > > How do I specify a named instance of SQL ? > > > WMI "SQL Server" InstanceName root\Microsoft\SqlServer > > \ComputerManagement > > > You will get plenty of doe samples- Hide quoted text - > > > - Show quoted text - > > ' enum protocols and show status > > set wmi = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer > \ComputerManagement") > > for each prop in wmi.ExecQuery("select * " & _ > > "from ServerNetworkProtocol " & _ > > "where InstanceName = 'mssqlserver'") > > WScript.Echo prop.ProtocolName & " - " & _ > > prop.ProtocolDisplayName & " " & _ > > prop.Enabled > > next > > ' enable named pipes > > for each changeprop in wmi.ExecQuery("select * " & _ > > "from ServerNetworkProtocol " & _ > > "where InstanceName = 'mssqlserver' and " & _ > > "ProtocolName = 'Np'") > > changeprop.SetEnable() > > next- Hide quoted text - > > - Show quoted text - from http://support.microsoft.com/default.aspx/kb/911839 If oArgs.Count <> 5 Then WScript.Echo "Usage: ChangeSQLServiceAccounts.vbs MachineName InstaNcename ServiceType SQLAccount SQLPassword" WScript.Echo "ServiceType = 1 (SQLServer), 2 (Agent), 3 (FTE), 4 (DTS), 5 (AS), 6 (RS), 7 (Browser)" WScript.Echo "Example: ChangeSQLServiceAccounts.vbs . MSSQLServer 1 BuiltIn\System NULL" WScript.Quit(1) Else ' Load the inputs into variables. strComputer = oArgs(0) strInstanceName = oArgs(1) strServiceType = oArgs(2) strAccountName = oArgs(3) strPassword = oArgs(4) End If ' Get a WMI object for the SQL namespace. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\ROOT\microsoft \sqlserver\ComputerManagement") ' Get an instance for this specific service. Set objSQLService = objWMIService.Get("SqlService.ServiceName=""" & strInstanceName & """,SQLServiceType=" & strServiceType) ' Obtain an InParameters object specific to the SQLService.SetServiceAccount method. Set objInParam = objSQLService.Methods_("SetServiceAccount").inPara meters.SpawnInstance_() ' Add the input parameters to the input object. objInParam.Properties_.item("ServiceStartName") = strAccountName objInParam.Properties_.item("ServiceStartPassword" ) = strPassword ' Call the SetServiceAccount method, and pass in the input object. Set objOutParams = objSQLService.ExecMethod_("SetServiceAccount", objInParam) 'Check the return to see whether there were any errors. If objOutParams.ReturnValue = 0 Then Wscript.Echo "The service account was changed to " & strAccountName Else Wscript.Echo "Could not change the service account to " & strAccountName & " due to error " & objOutParams.ReturnValue End If |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Thanks Steve.
|
|
![]() |
| Outils de la discussion | |
|
|