且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用不同的凭据调用 SQLCmd

更新时间:2021-09-06 22:37:24

遗憾的是我尝试了所有(包括 Matt 的建议),然后尝试了一些,但我无法在以下参数下使其工作.1) 该脚本是从作为 SYSTEM 帐户运行的服务启动的.2)系统与SQL集群位于不同的域/子网/等中.3) 查询必须实时运行并实时返回,因为查询只是较大脚本的一部分.

Sadly I tried it all (including Matt's suggestion) and then some and I just cant get it to work under the following parameters. 1) The script is launched from a service running as the SYSTEM account. 2) The system is in a separate domain/subnet/etc than the SQL cluster. 3) The query has to run real time and return in real time as the query is only part of a larger script.

现在我已经认输并创建了一个本地 SQL 登录来使用,然后将 Invoke-SQL 与 -username 和 -password 选项一起使用.这不是我想如何处理这种情况,但事实就是如此.谢谢大家!

For now I've thrown in the towel and created a local SQL login to use then use Invoke-SQL as is with the -username and -password options. It is not how I wanted to handle the situation BUT it is what it is. Thank you all!