PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.setup > WMI and Instance
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
ms.sqlserver.setup Questions about SQL Server.

WMI and Instance

Réponse
 
LinkBack Outils de la discussion
Vieux 03/03/2007, 02h35   #1
Michael Tissington
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut WMI and Instance

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 ?



  Réponse avec citation
Vieux 03/03/2007, 05h23   #2
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WMI and Instance

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 ?


Google
WMI "SQL Server" InstanceName root\Microsoft\SqlServer
\ComputerManagement

You will get plenty of doe samples



  Réponse avec citation
Vieux 03/03/2007, 06h23   #3
Michael Tissington
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WMI and Instance

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 ?


Google
WMI "SQL Server" InstanceName root\Microsoft\SqlServer
\ComputerManagement

You will get plenty of doe samples




  Réponse avec citation
Vieux 03/03/2007, 16h28   #4
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WMI and Instance

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 ?

>
> Google
> 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


  Réponse avec citation
Vieux 03/03/2007, 16h32   #5
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WMI and Instance

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 ?

>
> > Google
> > 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


  Réponse avec citation
Vieux 03/03/2007, 19h32   #6
Michael Tissington
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WMI and Instance

Thanks Steve.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h49.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14138 seconds with 14 queries