Skip to content

Commit

Permalink
Support multiple ports (do Set-DbaTcpPort)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasjordan committed Mar 31, 2024
1 parent 86b3f3d commit 95325ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions public/Set-DbaTcpPort.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Set-DbaTcpPort {
[PSCredential]$Credential,
[parameter(Mandatory)]
[ValidateRange(1, 65535)]
[int]$Port,
[int[]]$Port,
[IpAddress[]]$IpAddress,
[switch]$Force,
[switch]$EnableException
Expand All @@ -95,7 +95,7 @@ function Set-DbaTcpPort {
$computerFullName = $instance.ComputerName
$instanceName = $instance.InstanceName
if (-not $IpAddress) {
if ($Pscmdlet.ShouldProcess($instance, "Setting port to $Port for IPAll of $instance")) {
if ($Pscmdlet.ShouldProcess($instance, "Setting port to $($Port -join ',') for IPAll of $instance")) {
Set-DbaNetworkConfiguration -SqlInstance $instance -Credential $Credential -StaticPortForIPAll $Port -EnableException:$EnableException -Confirm:$false
}
} else {
Expand All @@ -113,13 +113,13 @@ function Set-DbaTcpPort {
if ($ipConf) {
$ipConf.Enabled = $true
$ipConf.TcpDynamicPorts = ''
$ipConf.TcpPort = "$Port" # change if [int[]]: $Port -join ','
$ipConf.TcpPort = $Port -join ','
} else {
Write-Message -Level Warning -Message "IP address $ip not found, skipping."
}
}

if ($Pscmdlet.ShouldProcess($instance, "Setting port to $Port for IP address $IpAddress of $instance")) {
if ($Pscmdlet.ShouldProcess($instance, "Setting port to $($Port -join ',') for IP address $IpAddress of $instance")) {
$netConf | Set-DbaNetworkConfiguration -Credential $Credential -EnableException:$EnableException -Confirm:$false
}

Expand Down

0 comments on commit 95325ca

Please sign in to comment.