Powershell – SQL PowerShell Snapin Problems

powershellsql

I am hoping this is an easy fix and oversight on my part. I need to be able to run the SQL cmdlets from remote machines. I have installed Microsoft® Windows PowerShell Extensions for SQL Server® 2008 R2 (along with the other requirements), however when I try to add the pssnapin I receive the error that the snap-in is not installed on this computer.

Add-PSSnapin : The Windows PowerShell snap-in 'SqlServerCmdletSnapin100' is not installed on this computer.

Any help?

Thank

Best Answer

If you installed the 2012 PowerShellTools.msi, then you need to reference SqlServerCmdletSnapin110 (you are specifying SqlServerCmdletSnapin100).

Also - it appears sometimes you have to register the DLLs even after running the Power ShellTools.msi install. Take a look at this post for details:

https://markcz.wordpress.com/2009/12/19/how-to-register-powershell-sql-server-snapin-in-windows-preinstalled-powershell/

Note that the path to the installutil may vary depending on what version(s) of the .NET framework you have installed and the path to the DLLs will vary depending on which version of the tools you installed. I have .NET 4, and the 2012 64-bit PowerShell tools installed, so here was what worked for me:

set-alias installutil $env:windir\microsoft.net\Framework64\v4.0.30319\installutil

installutil -i "C:\Program Files\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSProvider.dll"

installutil -i "C:\Program Files\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSSnapins.dll"

Given this is such an old post, you probably already got this resolved or found a workaround, but wanted to offer a solution for any folks that run into the problem in the future.