Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 2.75 KB

File metadata and controls

47 lines (32 loc) · 2.75 KB
title Run Windows PowerShell from SQL Server Management Studio | Microsoft Docs
ms.custom
ms.date 03/14/2017
ms.prod sql
ms.reviewer
ms.technology scripting
ms.topic conceptual
ms.assetid 1f841825-da1f-4062-9a81-3cdbab03845b
author markingmyname
ms.author maghan

Run Windows PowerShell from SQL Server Management Studio

[!INCLUDEappliesto-ss-asdb-asdw-pdw-md]

You can start Windows PowerShell sessions from Object Explorer in [!INCLUDEssManStudioFull]. [!INCLUDEssManStudio] launches Windows PowerShell, loads the SqlServer module, and sets the path context to the associated node in the Object Explorer tree.

Note

There are two SQL Server PowerShell modules; SqlServer and SQLPS. The SQLPS module is included with the SQL Server installation (for backwards compatibility), but is no longer being updated. The most up-to-date PowerShell module is the SqlServer module. The SqlServer module contains updated versions of the cmdlets in SQLPS, and also includes new cmdlets to support the latest SQL features.
Previous versions of the SqlServer module were included with SQL Server Management Studio (SSMS), but only with the 16.x versions of SSMS. To use PowerShell with SSMS 17.0 and later, the SqlServer module must be installed from the PowerShell Gallery. To install the SqlServer module, see Install SQL Server PowerShell.

When you specify running PowerShell for an object in Object Explorer, [!INCLUDEssManStudioFull] starts a Windows PowerShell session in which the [!INCLUDEssNoVersion] PowerShell snap-ins have been loaded and registered. The path for the session is preset to the location of the object you right-clicked in Object Explorer. For example, if you right-click the [!INCLUDEssSampleDBobject] database object in Object Explorer and select Start PowerShell, the Windows PowerShell path is set to the following:

SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks2012>  

Run PowerShell

To run PowerShell from SQL Server Management Studio

  1. Open Object Explorer.

  2. Navigate to the node for the object to be worked on.

  3. Right-click the object and select Start PowerShell.

Permissions

When opened from [!INCLUDEssManStudio], PowerShell does not run with Administrator privileges, which may prevent some activities such as calls to WMI.

See Also

SQL Server PowerShell