Invoke-Sqlcmd cmlet missing in Powershell core sqlserver module for linux

心已入冬 提交于 2019-12-14 03:50:04

问题


I am using latest version of Powershell core on Linux Ubuntu 16.04. I am trying to query a sql server database using powershell's invoke-sqlcmd cmdlet. (Yes I have installed the sqlserver module) I get an error which says that it cannot find the cmdlet. The command is there in windows powershell when I install the sqlserver module. Screenshot of the same

Does invoke-sqlcmd only work on Windows? If yes,is there another way I can achieve the same result in powershell core.


回答1:


In PowerShell Core, the sqlserver module doesn't export any of the Invoke-* cmdlets. However, there are the Read-SQLTableData and Read-SQLViewData cmdlets that appear to work in a similar fashion if you've already created views on the server side.




回答2:


With Powershell core (6.2.3 at the time of this writing), you can install the sql server module like so:

Install-Module -Name SqlServer

and then you can call invoke-sqlcmd

If you want to know more about it: http://sqlvariant.com/2019/03/invoke-sqlcmd-is-now-available-cross-platform-in-the-sqlserver-module/



来源:https://stackoverflow.com/questions/52210823/invoke-sqlcmd-cmlet-missing-in-powershell-core-sqlserver-module-for-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!