Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Quoting from <a href="http://msdn.microsoft.com/en-us/library/hh231286.aspx" rel="nofollow noreferrer">Import the SQLPS Module</a> on MSDN, </p> <blockquote> <p>The recommended way to manage SQL Server from PowerShell is to import the sqlps module into a Windows PowerShell 2.0 environment.</p> </blockquote> <p>So, yes, you could use the <code>Add-PSSnapin</code> approach detailed by Christian, but it is also useful to appreciate the recommended sqlps module approach.</p> <p>The simplest case assumes you have SQL Server 2012: <strong>sqlps</strong> is included in the installation so you simply load the module like any other (typically in your <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb613488%28v=vs.85%29.aspx" rel="nofollow noreferrer">profile</a>) via <code>Import-Module sqlps</code>. You can check if the module is available on your system with <code>Get-Module -ListAvailable</code>.</p> <p>If you do not have SQL Server 2012, then all you need do is download the <strong>sqlps</strong> module into your modules directory so Get-Module/Import-Module will find it. Curiously, Microsoft does <em>not</em> make this module available for download! However, Chad Miller has kindly packaged up the requisite pieces and provided <a href="http://sev17.com/2010/07/making-a-sqlps-module/" rel="nofollow noreferrer">this module download</a>. Unzip it under your ...Documents\WindowsPowerShell\Modules directory and proceed with the import.</p> <p>It is interesting to note that the module approach and the snapin approach are not identical. If you load the snapins then run <code>Get-PSSnapin</code> (<em>without</em> the -Registered parameter, to show only what you have loaded) you will see the SQL snapins. If, on the other hand, you load the sqlps module <code>Get-PSSnapin</code> will not show the snapins loaded, so the various blog entries that test for the <code>Invoke-Sqlcmd</code> cmdlet by only examining snapins could be giving a false negative result.</p> <p><strong>2012.10.06 Update</strong></p> <p>For the complete story on the sqlps module vs. the sqlps mini-shell vs. SQL Server snap-ins, take a look at my two-part mini-series <a href="http://www.simple-talk.com/sql/database-administration/practical-powershell-for-sql-server-developers-and-dbas-%E2%80%93-part-1/" rel="nofollow noreferrer">Practical PowerShell for SQL Server Developers and DBAs</a> recently published on Simple-Talk.com where I have, according to one reader's comment, successfully "de-confused" the issue. :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload