Skip to content

Commit

Permalink
Force $server.Databases for AzureSql - fixes #5621 (#5625)
Browse files Browse the repository at this point in the history
* fixes #5621

* cleaner
  • Loading branch information
potatoqualitee authored May 28, 2019
1 parent 8d4dc68 commit 9a23672
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion functions/Connect-DbaInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ function Connect-DbaInstance {
Add-Member -InputObject $server -NotePropertyName IsAzure -NotePropertyValue $true -Force
Add-Member -InputObject $server -NotePropertyName ComputerName -NotePropertyValue $instance.ComputerName -Force
Add-Member -InputObject $server -NotePropertyName DbaInstanceName -NotePropertyValue $instance.InstanceName -Force
Add-Member -InputObject $server -NotePropertyName NetPort -NotePropertyValue $instance.Port -Force -Passthru
Add-Member -InputObject $server -NotePropertyName NetPort -NotePropertyValue $instance.Port -Force
# Azure has a really hard time with $server.Databases, which we rely on heavily. Fix that.
$currentdb = $server.Databases | Where Name -eq $Database | Select-Object First 1
Add-Member -InputObject $server -NotePropertyName Databases -NotePropertyValue @{ $currentdb.Name = $currentdb } -Force -Passthru
continue
} catch {
Stop-Function -Message "Failure" -ErrorRecord $_ -Continue
Expand Down

0 comments on commit 9a23672

Please sign in to comment.