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.


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


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.

Please Share This:

You may also like:

2 Responses

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Subcribe to Blog Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

What I'm Saying on Twitter

Subscribe via feedburner