使用Invoke-SqlCmd时Powershell会话作为服务帐户无法找到SQL实例

时间:2019-03-28 15:56:41

标签: sql-server powershell database-connection

我有一个运行以下Powershell的管理员级别服务帐户:

Invoke-Sqlcmd -ServerInstance "DDB.MYservers.Corp\INSTNO" -Database BizTalkMgmtDb -Query "
    SELECT        bts_sendport.nvcName, bts_sendport_transport.nvcAddress, nPortStatus, bts_sendport_transport.dtFromTime, 
                  bts_sendport_transport.bIsServiceWindow, bts_sendport_transport.dtToTime,
                  adm_Adapter.Name As TransportTypeID, bts_application.nvcName AS Application
    FROM            bts_sendport With(NOLOCK) INNER JOIN
                             bts_sendport_transport ON bts_sendport.nID = bts_sendport_transport.nSendPortID 
                             INNER JOIN
                             bts_application ON bts_sendport.nApplicationID = bts_application.nID
                             INNER JOIN 
                             adm_Adapter ON bts_sendport_transport.nTransportTypeId = adm_Adapter.Id

    WHERE 
    nTransportTypeId IS NOT NULL

    "

对于我的大多数服务器,它返回我想要的信息,但是由于我公司的命名约定发生了一些变化,所以我使用故障转移群集管理器创建了一个服务器群集。我通过查看BizTalk属性来获得服务即时目标,并且如果我针对面向群集的BizTalk实例使用一个目标,则会出现以下错误:

Invoke-Sqlcmd : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was  not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote  connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], SqlException
    + FullyQualifiedErrorId : SqlExectionError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand ParserError: (:) [Invoke-Sqlcmd], ParserException
    + CategoryInfo          : ParserError: (:) [Invoke-Sqlcmd], ParserException
    + FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

我可以ping服务器作为服务帐户,并看到它在那里,这使我认为它是导致问题的实例。如果我使用个人帐户运行脚本,我会取回信息,但如果以与我具有相同访问级别的服务帐户身份运行,则会失败。我想知道是否以调用集群实例的方式丢失了某些东西?还是以前有人遇到过这个问题?

0 个答案:

没有答案