Skip to content
Permalink
Browse files

fix tenancy (#5965)

  • Loading branch information...
potatoqualitee committed Aug 14, 2019
1 parent 8ec064d commit e567262cb58908f10e8fec82186be11379b98e69
Showing with 5 additions and 2 deletions.
  1. +5 −2 functions/Connect-DbaInstance.ps1
@@ -468,8 +468,6 @@ function Connect-DbaInstance {
return
}

Write-Message -Level Verbose -Message "Creating 'Active Directory Interactive' connstring"
$azureconnstring = "Data Source=tcp:$instance;UID=dbatools;Initial Catalog=$Database;Authentication=Active Directory Interactive"
if (-not $SqlCredential) {
Stop-Function -Message "When using Tenant, SqlCredential must be specified."
return
@@ -483,11 +481,16 @@ function Connect-DbaInstance {
# https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/configure-always-encrypted-using-powershell?view=sql-server-2017
$sqlconn = New-Object System.Data.SqlClient.SqlConnection $azureconnstring
Write-Message -Level Verbose -Message $sqlconn.ConnectionString
# assign this twice, not sure why but hey it works better
if ($accesstoken) {
$sqlconn.AccessToken = $accesstoken
}
$serverconn = New-Object Microsoft.SqlServer.Management.Common.ServerConnection $sqlconn
Write-Message -Level Verbose -Message "Connecting to Azure: $instance"
# assign it twice, not sure why but hey it works better
if ($accesstoken) {
$serverconn.AccessToken = $accesstoken
}
$null = $serverconn.Connect()
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $serverconn
# Make ComputerName easily available in the server object

0 comments on commit e567262

Please sign in to comment.
You can’t perform that action at this time.