I have this PoweShell script code:
$sqlView = Read-SqlTableData -ServerInstance $query.Instance -DatabaseName $query.DB -SchemaName $query.Schema -TableName $query.View
I keep getting this error:
Read-SqlTableData : Failed to connect to server DB1.MYDOMAIN.COM.
At E:\scripts\EXPORT-DATA.ps1:59 char:24
The Windows service account NT AUTHORITY\NETWORK SERVICE do have Sysadmin permission in the DB1 sql server.
I'm able to run this script as a domain server admin but when I run this PowerShell script as Network Service, it always failed with that error above. It seems to be an issue with this service account but I'm not sure where else to check further since it's already set to sysadmin. Any help is much appreciated.