dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

New-DbaAvailabilityGroup - ensure encryption key exists

Open potatoqualitee opened this issue 3 years ago • 1 comments

Summarize Functionality

I did a demo on this which suggests it worked but I didn't see it in the code. This is an issue for me to ensure that encryption automatically works for all seeding modes.


# Introduce TDE and its 10 step process
1..5 | ForEach-Object { New-DbaDatabase -SqlInstance mssql1 -SqlCredential $cred -Name "testdb$PSItem" }

$params2 = @{
    SqlInstance             = "mssql1"
    SqlCredential           = $cred
    MasterKeySecurePassword = $cred.Password
    BackupSecurePassword    = $cred.Password
    BackupPath              = "/shared"
    AllUserDatabases        = $true
}
Start-DbaDbEncryption @params2 -Confirm:$false


# See backups
Get-DbaFile -SqlInstance mssql1 -SqlCredential $cred -Path /shared | Out-GridView

# See encrypted databases
Get-DbaDatabase -SqlInstance mssql1 -Encrypted | Out-GridView

# setup a powershell splat
$params = @{
    Primary                       = "mssql1"
    PrimarySqlCredential          = $cred
    Secondary                     = "mssql2"
    SecondarySqlCredential        = $cred
    Name                          = "test-ag"
    Database                      = "pubs"
    ClusterType                   = "None"
    SeedingMode                   = "Automatic"
    FailoverMode                  = "Manual"
    ConnectionModeInSecondaryRole = "AllowAllConnections"
    Confirm                       = $false
}
New-DbaAvailabilityGroup @params

# Show in SSMS then stop
Stop-DbaDbEncryption -SqlInstance mssql1 -SqlCredential $cred

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

thats all

potatoqualitee avatar Jun 02 '22 05:06 potatoqualitee

@potatoqualitee is this still a thing?

andreasjordan avatar May 31 '25 17:05 andreasjordan