Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Import the SQLPS Module


The recommended way to manage SQL Server from PowerShell is to import the sqlps module into a Windows PowerShell 2.0 environment. The module loads and registers the SQL Server snap-ins and manageability assemblies.

  1. Before You Begin: Security

  2. To load the module: Load the sqlps Module

After importing the sqlps module into Windows PowerShell, you can then:

  • Interactively run Windows PowerShell commands.

  • Run Windows PowerShell script files.

  • Run SQL Server cmdlets.

  • Use the SQL Server provider paths to navigate through the hierarchy of SQL Server objects.

  • Use the SQL Server manageability object models (such as Microsoft.SqlServer.Management.Smo) to manage SQL Server objects.


The verbs used in the names of two SQL Server cmdlets (Encode-Sqlname and Decode-Sqlname) do not match the approved verbs for Windows PowerShell 2.0. This has no effect on their operation, but Windows PowerShell raises a warning when the sqlps module is imported to a session.

By default, Windows PowerShell runs with the scripting execution policy set to Restricted, which prevents running any Windows PowerShell scripts. To load the sqlps module, you can use the Set-ExecutionPolicy cmdlet to enable running signed scripts, or any scripts. Only run scripts from trusted sources, and secure all input and output files using the appropriate NTFS permissions. For more information about enabling Windows PowerShell scripts, see Running Windows PowerShell Scripts.

To load the sqlps module in Windows PowerShell

  1. Use the Set-ExecutionPolicy cmdlet to set the appropriate script execution policy.

  2. Use the Import-Module cmdlet to import the sqlps module. Specify the DisableNameChecking parameter if you want to suppress the warning about Encode-Sqlname and Decode-Sqlname.

This example loads the sqlps module with name checking turned off.

## Import the SQL Server Module.

Import-Module “sqlps” -DisableNameChecking


If the sqlps module is not in your path, change to the location of the module or use the full path in the script (using double-quotes of folders in your path have spaces). The sqlps module is located in the Tools\Powershell folder for your SQL Server instance.

Arrow icon used with Back to Top link  Bookmark link 'Intro' is broken in topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"a972c56e-b2af-4fe6-abbd-817406e2c93a","entity_type":"Article","locale":"en-US"}'. Rebuilding the topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"a972c56e-b2af-4fe6-abbd-817406e2c93a","entity_type":"Article","locale":"en-US"}' may solve the problem.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft