2017-05-27 11 views
4

TDEで暗号化されたデータベースをセットアップしました。 PowerShellでこの暗号化を無効にする必要があります。私はいくつかの画期的な問題を抱えていますが、以下のエラーに直面していますpowershellでデータベースの暗号化を無効にする方法

エラー:データベース暗号化キーが現在使用中であるため、これを削除できません。データベース暗号化キーを削除できるようにするには、データベース暗号化をオフにする必要があります。しかし、暗号化キーはオフになりますが、キーは落ちてしまいます。 以下は、それが

enter image description here

Below is the code that I have written/used: 

    function set-EncryptionOff($ExistingDB) 
{ 
    $ExistingDB.EncryptionEnabled=$false 
    $ExistingDB.Alter(); 
    $ExistingDB.DatabaseEncryptionKey.Refresh() 
    $ExistingDB.DatabaseEncryptionKey.Drop() 

} 

答えて

3

あなたはとても近くです。 EncryptionEnabledをfalseに設定した後、実際にサーバーに指示するには、$ExistingDB.Alter()を実行する必要があります。これを実行したら、既に持っているコマンドを使用して安全にデータベースの暗号化キーを削除できます。

全スクリプト:

$sqlServer = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $sqlName 
$ExistingDB=$sqlServer.Databases.Item($dbname) 
$ExistingDB.EncryptionEnabled=$false 
$ExistingDB.Alter() 
$ExistingDB.DatabaseEncryptionKey.Refresh() 
$ExistingDB.DatabaseEncryptionKey.Drop() #should work now 
+0

こんにちはベン、おかげで入力..コードが正常に動作しました+ 1 – sanketh

+0

DBが巨大で解読が完了すると自動的にバックアップする必要があるため、DB解読の完了を識別するイベントリスナーはありますか – sanketh

+0

ここで実際に質問したようです:https://stackoverflow.com/questions/44225996/event-handler-for-tde-decryption-process-in-powershell/44229087回答はそこにある。 –

2

あなたがこれを行うには、AzureのPowerShellコマンドレットSet-AzureRMSqlDatabaseTransparentDataEncryptionを使用することができますように見えたコードの最初の実行後にどのように見えるかのスクリーンショットです:

Enabling and Disabling TDE on SQL Database by Using PowerShell

Using the Azure PowerShell you can run the following command to turn TDE on/off. You must connect your account to the PS window before running the command. Customize the example to use your values for the ServerName, ResourceGroupName, and DatabaseName parameters. For additional information about PowerShell, see How to install and configure Azure PowerShell .

を..

To disable TDE:

Set-AzureRMSqlDatabaseTransparentDataEncryption -ServerName "myserver" -ResourceGroupName "Default-SQL-WestUS" -DatabaseName 

"database1" -State "Disabled"

If using version 0.9.8 use the Set-AzureSqlDatabaseTransparentDataEncryption command.

出典:https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption-with-azure-sql-database

+0

セットAzureRMSqlDatabaseTransparentDataEncryptionが認識コマンドレットはありませんが、あなたはどのパッケージが含まれて教えてくださいできますか? – sanketh

+0

私はそれがAzureRMモジュールの一部だと信じていますhttps://docs.microsoft.com/en-gb/powershell/azure/install-azurerm-ps?view=azurermps-4.0.0 –

関連する問題