Skip to content

Commit

Permalink
Connect-DbaInstance - modify ComputerName resolution (#5687)
Browse files Browse the repository at this point in the history
* update connect command

* update comments, prettify linux
  • Loading branch information
potatoqualitee authored Jun 7, 2019
1 parent 21dc055 commit 8ef23ff
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion functions/Connect-DbaInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,20 @@ function Connect-DbaInstance {
continue
} else {
if (-not $server.ComputerName) {
# Not every environment supports .NetName
if ($server.DatabaseEngineType -ne "SqlAzureDatabase") {
try {
$computername = $server.NetName
} catch {
$computername = $instance.ComputerName
}
}
# SQL on Linux is often on docker and the internal name is not useful
if (-not $computername -or $server.HostPlatform -eq "Linux") {
$computername = $instance.ComputerName
}
Add-Member -InputObject $server -NotePropertyName IsAzure -NotePropertyValue $false -Force
Add-Member -InputObject $server -NotePropertyName ComputerName -NotePropertyValue $instance.ComputerName -Force
Add-Member -InputObject $server -NotePropertyName ComputerName -NotePropertyValue $computername -Force
Add-Member -InputObject $server -NotePropertyName DbaInstanceName -NotePropertyValue $instance.InstanceName -Force
Add-Member -InputObject $server -NotePropertyName NetPort -NotePropertyValue $instance.Port -Force
}
Expand Down

0 comments on commit 8ef23ff

Please sign in to comment.