Monday 4 May 2009

WMI script to enable TCP settings

This script returns the status of the TCP protocol settings and changes the status to enabled

set wmi = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement")
for each prop in wmi.ExecQuery("select * " & _
"from ServerNetworkProtocol " & _
"where InstanceName = 'sqltools'")
WScript.Echo prop.ProtocolName & " - " & _
prop.ProtocolDisplayName & " " & _
prop.Enabled
next
' enable tcpip
for each changeprop in wmi.ExecQuery("select * " & _
"from ServerNetworkProtocol " & _
"where InstanceName = 'sqltools' and " & _
"ProtocolName = 'Tcp'")
changeprop.SetEnable()
next

No comments:

Post a Comment

Note: only a member of this blog may post a comment.