This blog post is pretty interesting.
http://concentratedtech.com/content/index.php/2008/06/sql-server-2008-powershell-no-no-no-no-no/
Â
SQL Server 2008 comes with sqlps.exe, which is what this guy is ranting about.
Â
To get around it, you can do this. Open the regular powershell command prompt. Run this:
Â
notepad $profile
Â
This opens up the profile used by PowerShell under your login. Now you can add these lines and save the file:
Â
add-pssnapin SqlServerProviderSnapin100
add-pssnapin SqlServerCmdletSnapin100
Â
You should now be able to run SQL Server commands through the regular PowerShell prompt. Depending on how you configure and run Powershell, you may also have to add those lines to scripts you create.
Â
I may not have this quite right. I’m still learning. Here’s a suggestion that I should be updating the console file? He’s solving the same issue though.
Â
More as I learn more.
Well, if you don’t want to be typing those add-pssnapin commands every time you want to hook into SQL using powershell, then putting them into a console file can help.
That’s where I’m confused. I put them into the profile file and now I’m not typing them in any more. What’s the difference between placing them in the console and profile locations?
Actually, the point is that there’s no way to make SQL Server’s own tools, including SQL Server Agent, launch anything other than the mini-shell, which doesn’t support any span-ins except the SQL ones. PowerShell’s architect (Jeffrey Snover) later said that the concept was his suggestion, and that it may not have been the best possible solution, in the end.
Hi…i can use the cmdlet add-pssanpin and all “snapin” cmdlets related ins SQLPS.exe…why ?…how can i do to use ?
If I understand the question, you can add the SQL Server snapins to a regular shell. It’s the mini-shell used by the SQL Server tools that allows a very limited sub-set of snapins.
I’m still learning this stuff, so I wouldn’t rely completely on what I’m saying here.