I have a powershell script that is invoked from a Powershell build step in TFS. The powershell script works fine both on my dev PC and the build server when invoked from the command line. The script uses Invoke-Sqlcmd
to execute some SQL.
However, when the script is executed from the TFS build, it errors with the following:
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. How do I get this to work from TFS?
The Invoke-Sqlcmd
cmdlet is part of the SQLPS Module .
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.
https://technet.microsoft.com/en-us/library/hh231286(v=sql.110).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.