简体   繁体   English

Powershell无法从TFS Build中找到Invoke-Sqlcmd

[英]Powershell can't find Invoke-Sqlcmd from a TFS Build

I have a powershell script that is invoked from a Powershell build step in TFS. 我有一个PowerShell脚本,可以从TFS中的Powershell构建步骤调用。 The powershell script works fine both on my dev PC and the build server when invoked from the command line. 从命令行调用时,powershell脚本在我的开发PC和构建服务器上都能正常工作。 The script uses Invoke-Sqlcmd to execute some SQL. 该脚本使用Invoke-Sqlcmd来执行某些SQL。

However, when the script is executed from the TFS build, it errors with the following: 但是,当从TFS构建执行脚本时,它会出现以下错误:

The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

This only occurs from with TFS so I'm having difficulty figuring out how to fix it. 这只发生在TFS上,所以我很难弄清楚如何修复它。 How do I get this to work from TFS? 如何从TFS中使用它?

The Invoke-Sqlcmd cmdlet is part of the SQLPS Module . Invoke-Sqlcmd cmdlet是SQLPS模块的一部分。

As the error states, the module is not visible for the scope of the session you are invoking that script from (for some reason). 正如错误所述,模块对于您正在调用该脚本的会话范围(由于某种原因)不可见。 Maybe, just an Import-Module sqlps -DisableNameChecking inside the script would make it available. 也许,只是脚本中的Import-Module sqlps -DisableNameChecking会使它可用。

https://technet.microsoft.com/en-us/library/hh231286(v=sql.110).aspx https://technet.microsoft.com/en-us/library/hh231286(v=sql.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM