0

I am looking for getting a password for azure sql db if we have user name using powershell. I found Get-AzureRmSqlDatabaseSecureConnectionPolicy cmdlet to get connection string but it does not have password. Any help would be appreciated.

Thanks, Paul

2 Answers 2

3

As far as know, it is not possible. If you could get the password by using PowerShell, I think it is unsafe. Azure does not allow this.

But, you could reset SQL DB password by using PowerShell. Just use Set-AzureRmSqlServer.

PS C:\>$ServerPassword = "newpassword"
PS C:\> $SecureString = ConvertTo-SecureString $ServerPassword -AsPlainText -Force
PS C:\> Set-AzureRmSqlServer -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -SqlAdministratorPassword $secureString
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Walter. Even I guess the same based on the available documentation.
0

When you created your SQL Azure database you were required to provide the name of an Admin user and its password. You can then use your Admin user to run PowerShell scripts involving SQL Azure database as shown below:

# The data center and resource name for your resources
$resourcegroupname = "myResourceGroup"
$location = "WestEurope"
# The logical server name: Use a random value or replace with your own value (do not capitalize)
$servername = "server-$(Get-Random)"
# Set an admin login and password for your database
# The login information for the server
$adminlogin = "ServerAdmin"
$password = "ChangeYourAdminPassword1"
# The ip address range that you want to allow to access your server - change as appropriate
$startip = "0.0.0.0"
$endip = "0.0.0.0"
# The database name
$databasename = "mySampleDatabase"

To create SQL Database users using PowerShell, please read this article.

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.