Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlcmd connect using active mfa authentication

Can anyone instruct how to connect to a remote SQL Server database using active MFA authentication? What command should be used to connect?

like image 205
Henry Avatar asked Sep 24 '26 19:09

Henry


1 Answers

If you are referring to Authenticating using AzureAD with MFA then you just need to use the -G switch without supplying a password. You will be prompted for the password and the MFA challenge.

$serverName = 'contososql.database.windows.net';
$userName="[email protected]" # Azure AD username
$databaseName='contoso1'

Sqlcmd -S $serverName -d $databaseName -U $userName -G -I
like image 174
JLove Avatar answered Sep 27 '26 14:09

JLove



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!