Blog Post

Invoke-Sqlcmd is Now Available Cross-Platform in the SqlServer module

,

Invoke-Sqlcmd is Now Available for MacOS & Linux in the SqlServer module.  The module has been posted as v21.1.18095-preview which means to download the module you’ll have to add the -AllowPrerelease parameter.

Update-Module SqlServer -AllowPrerelease

But wait, there’s more.  In order to use the Invoke-Sqlcmd cmdlet on PSCore you’ll also need to download PSCore 6.2 which, as of this writing, is currently in Release Candidate status.  I guess that makes this sort of a double-preview Smile

For information on how to “installing a PowerShell Core Preview release for Linux” check out the docs page.

If you’re on a Mac, you’ll currently need to run pwsh-preview to launch v6.2 of PSCore.  Once you have the module updated & PSCorev6.2 installed you’re ready to go.  Nothing else needed.

clip_image002

To install PSCore v6.2 on MacOS, after you have run ‘brew cask install powershell’ then run the following code to allow it to access the preview version:

brew tap homebrew/cask-versions

After that, run this to install the preview version of PSCore:

brew cask install powershell-preview

Finally, to launch the preview version of PSCore run the command below and off you go

pwsh-preview

If you’re still on an earlier version of PSCore and are unable to install PSCore 6.2 right now, you can still download preview of the SqlServer module to get the latest fixes and new features.  You just won’t be able to use the Invoke-Sqlcmd cmdlet.

Another quick thing to note is that this is like a v.0.0.1 of Invoke-SqlCmd on PSCore; it does not have all the bells & whistles of the version of Invoke-Sqlcmd for [full blown] Windows PowerShell.  Obviously, more features will be added over time, but the basic functionality was ready to for customers to start “kicking the tires”.

The functionality listed in the release notes notes are as follows:

* Initial support for Invoke-Sqlcmd on .Net Core (-Variable, -DisableVariables, -DisableCommand,

 -QueryTimeout, -ConnectionTimeout, -Hostname not supported yet). ”

If you run into an issue with the cmdlet, please do comment on the PowerShell Gallery page for the SqlServer module, Matteo is really good about responding there.

The post Invoke-Sqlcmd is Now Available Cross-Platform in the SqlServer module first appeared on SQLvariations: SQL Server, a little PowerShell, maybe some Power BI.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating