Forked from FeodorFitsner/sql-server-all-enable-dynamic-tcp.ps1
Last active
September 6, 2018 04:31
-
-
Save fireflycons/58dfde9c2fab7de2f4e97668938baebe to your computer and use it in GitHub Desktop.
Enable dynamic TCP ports for all SQL Server instances (so they can be run simultaneously)
This file contains hidden or 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
<# | |
.SYNOPSIS | |
Set all installed instances of SQL server to dynamic ports | |
#> | |
Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\' | | |
Where-Object { | |
$_.Name -imatch 'MSSQL[_\d]+\.SQL.*' | |
} | | |
ForEach-Object { | |
Write-Host "Setting $((Get-ItemProperty $_.PSPath).'(default)') to dynamic ports" | |
Set-ItemProperty (Join-Path $_.PSPath 'mssqlserver\supersocketnetlib\tcp\ipall') -Name TcpDynamicPorts -Value '0' | |
Set-ItemProperty (Join-Path $_.PSPath 'mssqlserver\supersocketnetlib\tcp\ipall') -Name TcpPort -Value ([string]::Empty) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment