Can anyone instruct how to connect to a remote SQL Server database using active MFA authentication? What command should be used to connect?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With