Created
August 25, 2015 19:59
WMI script to configure IPAll properties for SQL Server TCP Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set wmiComputer = GetObject( _ | |
"winmgmts:" _ | |
& "\\.\root\Microsoft\SqlServer\ComputerManagement12") | |
set tcpProperties = wmiComputer.ExecQuery( _ | |
"select * from ServerNetworkProtocolProperty " _ | |
& "where InstanceName='MSSQLSERVER' and " _ | |
& "ProtocolName='Tcp' and IPAddressName='IPAll'") | |
for each tcpProperty in tcpProperties | |
dim setValueResult, requestedValue | |
if tcpProperty.PropertyName = "TcpPort" then | |
requestedValue = "1433" | |
elseif tcpProperty.PropertyName ="TcpDynamicPorts" then | |
requestedValue = "0" | |
end if | |
setValueResult = tcpProperty.SetStringValue(requestedValue) | |
if setValueResult = 0 then | |
Wscript.Echo "" & tcpProperty.PropertyName & " for IPAll set." | |
else | |
Wscript.Echo "" & tcpProperty.PropertyName & " for IPAll failed!" | |
end if | |
next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment