Advertisement
Guest User

Untitled

a guest
May 14th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. netsh firewall set portopening protocol = TCP port = 1433 name = SQLPort mode = ENABLE scope = SUBNET profile = CURRENT
  2.  
  3. ALTER LOGIN [sa] WITH PASSWORD='*****newPassword****'
  4.  
  5. SQLCMD -U sa -P newPassword -S 192.168.0.120SQLEXPRESS,1433
  6.  
  7. set wmiComputer = GetObject( _
  8. "winmgmts:" _
  9. & "\.rootMicrosoftSqlServerComputerManagement10")
  10. set tcpProtocols = wmiComputer.ExecQuery( _
  11. "select * from ServerNetworkProtocol " _
  12. & "where InstanceName = 'SQLEXPRESS' and ProtocolName = 'Tcp'")
  13.  
  14. if tcpProtocols.Count = 1 then
  15. ' set tcpProtocol = tcpProtocols(0)
  16. ' I wish this worked, but unfortunately
  17. ' there's no int-indexed Item property in this type
  18.  
  19. ' Doing this instead
  20. for each tcpProtocol in tcpProtocols
  21. dim setEnableResult
  22. setEnableResult = tcpProtocol.SetEnable()
  23. if setEnableResult <> 0 then
  24. Wscript.Echo "Failed!"
  25. end if
  26. next
  27. end if
  28.  
  29. set wmiComputer = GetObject( _
  30. "winmgmts:" _
  31. & "\.rootMicrosoftSqlServerComputerManagement10")
  32. set tcpProperties = wmiComputer.ExecQuery( _
  33. "select * from ServerNetworkProtocolProperty " _
  34. & "where InstanceName='SQLEXPRESS' and " _
  35. & "ProtocolName='Tcp' and IPAddressName='IPAll'")
  36.  
  37. for each tcpProperty in tcpProperties
  38. dim setValueResult, requestedValue
  39.  
  40. if tcpProperty.PropertyName = "TcpPort" then
  41. requestedValue = "3456"
  42. elseif tcpProperty.PropertyName ="TcpDynamicPorts" then
  43. requestedValue = ""
  44. end if
  45.  
  46. setValueResult = tcpProperty.SetStringValue(requestedValue)
  47. if setValueResult = 0 then
  48. Wscript.Echo "" & tcpProperty.PropertyName & " set."
  49. else
  50. Wscript.Echo "" & tcpProperty.PropertyName & " failed!"
  51. end if
  52. next
  53.  
  54. SQLCMD -U sa -P newPassword -S 192.168.0.120,3456
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement