-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

2 Answers 2

0

Use the Set-AzureRmSqlDatabaseTransparentDataEncryption cmdlet

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks ,but How can I loop through each database one at the time to execute Set-AzureRmSqlDatabaseTransparentDataEncryption in powershell script?
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' }
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.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.