Thursday, November 06, 2014

The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet

On my new Windows 7 machine while inside Powershell I tried "Invoke-Sqlcmd", but kept getting the error message "The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet".
Here was my solution:

Download the SQL Server® 2008 R2 Feature Pack from here.

Then click on the "Instructions" plus symbol.

Then search for "Microsoft® Windows PowerShell Extensions for SQL Server® 2008 R2" and select the appropriate download.

Now after installing, go inside Powershell and execute "Add-PSSnapin SqlServerCmdletSnapin100", then Invoke-SqlCmd worked for me.
To add it permanently, edit your profile and add "Add-PSSnapin SqlServerCmdletSnapin100". (You can find your profile location by executing "$profile").

No comments: