My task is to execute Azure MI database SP using Powershell.
I am using connection string. I believe I am able to login to the SQLMI database using the connection string with PowerShell.
However, I am getting an error while running the SQL. Below is the code and exception. Could you please help me?
$managedInstanceName = "MI"
$databaseName = "DB"
$serverAdminLogin = "t1"
$serverAdminPassword = "t1"
$query = "execute dbo.SP1"
$connectionString = "Server=tcp:$managedInstanceName.database.windows.net,1433;Persist Security Info=False;UserID=$serverAdminLogin;Password=$serverAdminPassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Invoke-Sqlcmd -ServerInstance $managedInstanceName -Database $databaseName -Query "execute dbo.SP1"
Error:'Invoke-Sqlcmd' is not recognized as the name of a cmdlet.