-1

I am trying to create a PowerShell script that loops through each user database in Azure SQL server supplied as a parameter and enable the TDE and return the status.

How can I create a PowerShell script for that? Can you show me some examples?

Thank you

jk2016
  • 29
  • 3

2 Answers2

0

Use the Set-AzureRmSqlDatabaseTransparentDataEncryption cmdlet

itaysk
  • 5,852
  • 2
  • 33
  • 40
  • Thanks ,but How can I loop through each database one at the time to execute Set-AzureRmSqlDatabaseTransparentDataEncryption in powershell script? – jk2016 Oct 16 '16 at 23:06
  • I have something like this so far to loop though azure sql user databases in a server,,,, I am not sure how to loop through databases one at the time Login-AzureRMAccount $AzureSQLServer = Get-AzureRmSqlServer -ResourceGroupName $AzureSQLdatabases =Get-AzureRmSqlDatabase -ResourceGroupName "test" -ServerName $AzureSQLServer $AzureSQLDatabase= ?? singledatabe # loop through each user databases in Azure SQL Server foreach ($AzureSQLDatabase in $AzureSQLdatabases) { Set-AzureRMSqlDatabaseTransparentDataEncryption -State 'Enabled' } – jk2016 Oct 16 '16 at 23:33
  • Do you successfully get the $AzureSQLdatabases variable? If so, then the only thing I see missing is to specify the DB to operate on. delete the line where you have `$AzureSQLDatabase= ?? singledatabe` and in the line inside the loop, pipe the current DB to the cmdlet like so `$AzureSQLDatabase | Set-AzureRMSqlDatabaseTransparentDataEncryption -State Enabled`. – itaysk Oct 17 '16 at 17:10
0

You can iterate through each database this way: Azure PowerShell - Extracting Azure SQL Database information

Then change the code and adapt it to TDE.

Francesco Mantovani
  • 10,216
  • 13
  • 73
  • 113