Contents

Terraform - Uploading Static Content to Cloud

Views

The term ‘Invoke-sqlcmd’ is not recognized as the name of a cmdlet, function, script file, or operable.

Common error

Invoke-sqlcmd : The term ‘Invoke-sqlcmd’ is not recognized as the name of a cmdlet, function, script file, or operable

Solution

Install the Microsoft SQL Server 2016 Feature Pack’s PowerShell Extensions for SQL Server. You’ll be able to run 'Invoke-sqlcmd' in Powershell after it’s installed.

Download MSI packages

Download below installation files from Microsoft® SQL Server® 2016 Feature Pack site.

  • Microsoft® System CLR Types for Microsoft SQL Server® 2016 (SQLSysClrTypes.msi)
  • Microsoft® SQL Server® 2016 Shared Management Objects (SharedManagementObjects.msi)
  • Microsoft® Windows PowerShell Extensions for Microsoft SQL Server® 2016 (PowerShellTools.msi)

Install them following below order

  1. SQLSysClrTypes.msi
  2. SharedManagementObjects.msi
  3. PowerShellTools.msi

Reboot or downtimes are not required.

Validation

After installation open a new PS window and that should be working. You can try below syntax to query any SQL instance.

Invoke-sqlcmd -ServerInstance “Server\Instance” -Query “SELECT GETDATE() AS TimeOfQuery”

TimeOfQuery ———– 7/5/2018 6:51:57 PM

It’s a solution for the error 'Invoke-sqlcmd' is not recognized as a cmdlet, function, script file, or operable.' Now that it’s working, we can get back to work.