Updated: Jan 11, 2022
The article How to configure a static port for SQL Server? Explains the process of setting a non-default static port using SQL Server Configuration Manager. Can we do the same task using PowerShell Script?
Yes, we can set SQL Server static port using a PS script. Take the script from GitHub and open it in the Windows PowerShell IDE.
Specify the SQL Instance name ( in case of named instance) and SQL static port that we want to set. Execute the PowerShell script, and it sets static port followed by a restart SQL Service to take new port in effect.