How can one authenticate with AzAD while using Read-SqlTableData to read AzSQL tables
1
vote
2
answers
400
views
How should one specify the
Expecting screenshot or screenclip GIF that the answer code is working for an AzAD **user**id on AzSQL using
User ID
while creating the $sqlcc
object when using Read-SqlTableData to read a table in AzSQL with an Azure account ?
$sqlcc = new-object ('System.Data.SqlClient.SqlConnection') "Data Source= .database.windows.net;User ID=@.onmicrosoft.com;Password="
$sc = new-object ('Microsoft.SqlServer.Management.Common.ServerConnection') $sqlcc
$srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') $sc
$db = $srv.Databases["TestDB"]
$table = $db.Tables["TestTable"]
Read-SqlTableData -TopN 10 -InputObject $table
The code above is working for SQL ids but not for Azure ids. Specifying the User ID
like @.onmicrosoft.com
or @
causes the $srv
object to be blank.

Read-SqlTableData
.
Asked by Ayan Mullick
(115 rep)
Mar 26, 2022, 02:58 AM
Last activity: Apr 14, 2022, 01:06 PM
Last activity: Apr 14, 2022, 01:06 PM