| title | sqlps Utility | ||
|---|---|---|---|
| description | The sqlps utility starts a Windows PowerShell session with the SQL Server PowerShell provider and cmdlets loaded and registered. | ||
| author | rwestMSFT | ||
| ms.author | randolphwest | ||
| ms.date | 12/16/2025 | ||
| ms.service | sql | ||
| ms.subservice | tools-other | ||
| ms.topic | concept-article | ||
| ms.collection |
|
||
| ms.custom |
|
||
| helpviewer_keywords |
|
||
| monikerRange | >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =fabric-sqldb |
[!INCLUDE SQL Server Azure SQL Database Synapse Analytics PDW FabricSQLDB]
The sqlps utility starts a Windows PowerShell session with the [!INCLUDE ssNoVersion] PowerShell provider and cmdlets loaded and registered. You can enter PowerShell commands or scripts that use the [!INCLUDE ssNoVersion] PowerShell components to work with instances of [!INCLUDE ssNoVersion] and their objects.
Important
[!INCLUDE ssNoteDepFutureAvoid] Use the sqlps PowerShell module instead. For more information about the sqlps module, see Import the SQLPS Module.
sqlps
[ [ [ -NoLogo ] [ -NoExit ] [ -NoProfile ]
[ -OutPutFormat { Text | XML } ] [ -InPutFormat { Text | XML } ]
]
[ -Command { -
| script_block [ -args argument_array ]
| string [ command_parameters ]
}
]
]
[ -? | -Help ]Specifies that the sqlps utility hide the copyright banner when it starts.
Specifies that the sqlps utility continue running after the startup commands have completed.
Specifies that the sqlps utility not load a user profile. User profiles record commonly used aliases, functions, and variables for use across PowerShell sessions.
Specifies that the sqlps utility output is formatted as either text strings (Text) or in a serialized CLIXML format (XML).
Specifies that input to the sqlps utility is formatted as either text strings (Text) or in a serialized CLIXML format (XML).
Specifies the command for the sqlps utility to run. The sqlps utility runs the command and then exits, unless -NoExit is also specified. Don't specify any other switches after -Command. They're read as command parameters.
-Command- specifies that the sqlps utility read the input from the standard input.
Specifies a block of PowerShell commands to run, the block must be enclosed in braces: {}. Script_block can only be specified when the sqlps utility is called from either PowerShell or another sqlps utility session. The argument_array is an array of PowerShell variables containing the arguments for the PowerShell commands in the script_block.
Specifies a string that contains the PowerShell commands to be run. Use the format "{<command>}". The quotation marks indicate a string, and the invocation operator (&) causes the sqlps utility to run the command (<command>).
Shows the syntax summary of the sqlps utility options.
The sqlps utility starts the PowerShell environment (PowerShell.exe) and loads the [!INCLUDE ssNoVersion] PowerShell module. The module, also named sqlps, loads and registers these [!INCLUDE ssNoVersion] PowerShell snap-ins:
-
Microsoft.SqlServer.Management.PSProvider.dllImplements the [!INCLUDE ssNoVersion] PowerShell provider and associated cmdlets such as Encode-SqlName and Decode-SqlName.
-
Microsoft.SqlServer.Management.PSSnapin.dllImplements the Invoke-Sqlcmd and Invoke-PolicyEvaluation cmdlets.
You can use the sqlps utility to do the following tasks:
-
Interactively run PowerShell commands.
-
Run PowerShell script files.
-
Run [!INCLUDE ssNoVersion] cmdlets.
-
Use the [!INCLUDE ssNoVersion] provider paths to navigate through the hierarchy of [!INCLUDE ssNoVersion] objects.
By default, the sqlps utility runs with the scripting execution policy set to Restricted. This prevents running any PowerShell scripts. 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 by using the appropriate NTFS permissions. For more information about enabling PowerShell scripts, see Running Windows PowerShell Scripts.
The version of the sqlps utility in [!INCLUDE sql2008-md] and [!INCLUDE sql2008r2] was implemented as a Windows PowerShell 1.0 mini-shell. Mini-shells have certain restrictions, such as not allowing users to load snap-ins other than those snap-ins loaded by the mini-shell. These restrictions don't apply to the [!INCLUDE ssSQL11] and later versions of the utility, which have been changed to use the sqlps module.
sqlps -NoLogosqlps -Command "&{.\MyFolder.MyScript.ps1}"C. Run a SQL Server PowerShell script from the command prompt, and keep running after the script completes
sqlps -NoExit -Command "&{.\MyFolder.MyScript.ps1}"