Execution Flow
The SQL Server Browser service and SQL Server service must be restarted manually after the port change takes effect. Dynamic port assignment (
TcpDynamicPorts) is cleared automatically when a static port is set. Remote registry access requires appropriate permissions and the RemoteRegistry service running on the target.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Required | SQL Server instance. Format: Server or Server\Instance. |
| -BasePort | Int | Optional | Base TCP port. Default: 1433. |
| -PortIncrement | Int | Optional | Port offset per instance number. Default: 10. |
| -InstanceNumber | Int | Optional | Instance number for port calculation: Port = BasePort + PortIncrement × InstanceNumber. Default: -1 (use BasePort directly). |
Return Value
Returns a PSCustomObject with: SqlInstance, Port, PreviousPort, Status, Message.
Examples
Example 1 — Set default instance to port 1433
Set-sqmTcpPort -SqlInstance "SQL01"
Example 2 — Named instance with calculated port (1433 + 10×2 = 1453)
Set-sqmTcpPort -SqlInstance "SQL01\INST02" -BasePort 1433 -PortIncrement 10 -InstanceNumber 2
Example 3 — Explicit port without calculation
Set-sqmTcpPort -SqlInstance "SQL01\NAMED" -BasePort 1455