2

I am unable to use invoke-sqlcmd in powershell. I've loaded the module written by Chad Miller as described here: Problems using SQL Server 2008 R2 PowerShell extensions outside of SQLPS

The module loads just fine without error, and using get-module shows sqlps as expected. However, using get-pssnapin does not show either SqlServerCmdletSnapin100 or SqlServerProviderSnapin100

When I type invoke-sqlcmd I get the error "The term 'invoke-sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program..."

Running Windows 7 Pro, have SQL Server Management Studio Express 2008R2, have installed SQL Server 2008R2 Management Objects.

Thanks for any help Jon

5
  • When you run Get-PSSnapin are you using the -registered switch? Otherwise, it's only going to show you the snapins that are already loaded. Commented Sep 20, 2012 at 21:40
  • Using the -registered switch returns nothing. Commented Sep 20, 2012 at 22:00
  • Is the snapin bit-specific? Are you trying this from a 64-bit PowerShell prompt? If so, try an x86 prompt. Commented Sep 20, 2012 at 22:53
  • Rookie mistake - the module was unsigned and I had execution policy set to remotesigned - all better now. Running the install with verbose turned on caught it. Thanks for the help. Commented Sep 20, 2012 at 23:30
  • Also, the module was located in my profile which was on a network share - that doesn't work either. Needs to be physically on the same box. Commented Sep 20, 2012 at 23:37

2 Answers 2

3

I have similar problem:) This what i did: Register dll from sql files:

set-alias installutil $env:windir\microsoft.net\framework\v2.0.50727\installutil
installutil -i "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist\Microsoft.SqlServer.Management.PSProvider.dll"
installutil -i "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist\Microsoft.SqlServer.Management.PSSnapins.dll" 

Then you can check by: get-PSSnapin -registered

and now add snapins:

Add-PSSnapin SqlServerCmdletSnapin100   
Add-PSSnapin SqlServerProviderSnapin100

That works for me. Hope it helps...

Sorry for my english:)

Sign up to request clarification or add additional context in comments.

Comments

0

In my case, this issue was solved installing Microsoft® Windows PowerShell Extensions for Microsoft® SQL Server® 2012 and Microsoft® SQL Server® 2012 Shared Management Objects both included in Microsoft® SQL Server® Feature Pack

Download link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=29065

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.