Hello,
I am referring this article (https://docs.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps - example11) to use Invoke-SqlCMD to execute SQL Script from powershell using service principa
l I am using the below code to execute it from powershell script task
Import-Module SQLServer
Import-Module Az.Accounts -MinimumVersion 2.2.0
# If you already have your Access Token available, you can skip this section
# and just pass it to the cmdlet.
# Note: the sample assumes that you or your DBA configured the server to accept connections using
# that Service Principal and has granted it access to the database (in this example at least
# the SELECT permission).
### Obtain the Access Token: there are many ways to do it, this is one of them
Connect-AzAccount
$access_token = (Get-AzAccessToken -ResourceUrl https://database.windows.net).Token
Invoke-Sqlcmd -ServerInstance myserver.database.windows.net -Database mydb -AccessToken $access_token`
-query 'select * from Table1'
But it is not working and getting below error:

Any help would be appreciated