Skip to content

Commit 264d662

Browse files
committed
Made changes based on suggestions from PR by Matteo
1 parent 6f79235 commit 264d662

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

docs/powershell/download-sql-server-ps-module.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.technology: scripting
55
ms.topic: conceptual
66
author: markingmyname
77
ms.author: maghan
8-
ms.reviewer: carlrab
8+
ms.reviewer: matteot, aanelson
99
ms.custom: ""
1010
ms.date: 06/10/2020
1111
---
@@ -21,7 +21,8 @@ This article provides directions for installing the **SqlServer** PowerShell mod
2121
There are two SQL Server PowerShell modules:
2222

2323
- **SqlServer**: The SqlServer module includes new cmdlets to support the latest SQL features. The module also contains updated versions of the cmdlets in **SQLPS**. To download the SqlServer module, go to [SqlServer module in the PowerShell Gallery](https://www.powershellgallery.com/packages/Sqlserver).
24-
- **SQLPS**: The SQLPS module is included with the SQL Server installation (for backward compatibility), but is no longer being updated. The most up-to-date PowerShell module is the **SqlServer** module.
24+
25+
- **SQLPS**: The SQLPS is the module used by SQL Agent to run agent jobs in agent job steps using the PowerShell subsystem.
2526

2627
> [!NOTE]
2728
> The versions of the **SqlServer** module in the PowerShell Gallery support versioning and require PowerShell version 5.0 or greater.
@@ -48,6 +49,8 @@ You can use the [PowerShell extension](../azure-data-studio/powershell-extension
4849

4950
To install the **SqlServer** module from the PowerShell Gallery, start a [PowerShell](/powershell/scripting/overview) session as an administrator. You can also start Azure Data Studio as an administrator and run these commands in a PowerShell session in the integrated terminal.
5051

52+
You can also use *Install-Module SQLServer -Scope CurrentUser* to run elevated permissions. This cmdlet is useful for users who aren't administrators in their environment. However, since the scope is limited to the current user, other users on the same machine can't see the module.
53+
5154
### Install the SqlServer module
5255

5356
Run the following command in your PowerShell session to install the SqlServer module for all users:

docs/powershell/sql-server-powershell.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,23 @@ To install the **SqlServer** module, see [Install SQL Server PowerShell](downloa
2929

3030
To ship SQL PowerShell updates, we had to change the identity of the SQL PowerShell module, and the wrapper known as *SQLPS.exe*. Because of this change, there are now two SQL PowerShell modules, the **SqlServer** module, and the **SQLPS** module.
3131

32-
**Update your PowerShell scripts if they import the SQLPS module.**
32+
**Update your PowerShell scripts if you import the SQLPS module.**
3333

3434
If you have any PowerShell scripts that run `Import-Module -Name SQLPS`, and you want to take advantage of the new provider functionality and new cmdlets, you must change them to `Import-Module -Name SqlServer`. The new module is installed to `%ProgramFiles%\WindowsPowerShell\Modules\SqlServer` folder. As such, you don't have to update the $env:PSModulePath variable. If you have scripts that use a third-party or community version of a module named **SqlServer**, use the Prefix parameter to avoid name collisions.
3535

36+
It is recommended to start your script with *Import-Module SQLServer* to avoid side-by-side issues if the SQLPS module is installed on the same machine.
37+
38+
This section applies to scripts executed from PowerShell and not the SQL Agent. The new module can be used with SQL Agent job steps using [#NOSQLPS](#sql-server-agent).
39+
3640
## SQL Server PowerShell Components
3741

38-
The **SqlServer** module loads two Windows PowerShell snap-ins:
42+
The **SqlServer** module comes with:
43+
44+
- [Powershell Providers](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_providers), which enables a simple navigation mechanism similar to file system paths. You can build paths similar to file system paths, where the drive is associated with a SQL Server management object model, and the nodes are based on the object model classes. You can then use familiar commands such as **cd** and **dir** to navigate the paths similar to the way you navigate folders in a command prompt window. You can use other commands, such as **ren** or **del**, to perform actions on the nodes in the path.
3945

40-
- A SQL Server provider, which enables a simple navigation mechanism similar to file system paths. You can build paths similar to file system paths, where the drive is associated with a SQL Server management object model, and the nodes are based on the object model classes. You can then use familiar commands such as **cd** and **dir** to navigate the paths similar to the way you navigate folders in a command prompt window. You can use other commands, such as **ren** or **del**, to perform actions on the nodes in the path.
46+
- A set of cmdlets that support actions such as running a **sqlcmd** script containing Transact-SQL or XQuery statements.
4147

42-
- A set of cmdlets that support actions such as running a **sqlcmd** script containing [!INCLUDE[tsql](../includes/tsql-md.md)] or XQuery statements.
48+
- The AS provider and cmdlets, which before they were installed separately.
4349

4450
## SQL Server Versions
4551

@@ -57,7 +63,7 @@ Query expressions are strings that use syntax similar to XPath to specify a set
5763

5864
## SQL Server Agent
5965

60-
There's no change to the module used by SQL Server Agent. As such, SQL Server Agent jobs, which have job steps of the type PowerShell use the SQLPS module. For more information, see [How to run PowerShell with SQL Server Agent](run-windows-powershell-steps-in-sql-server-agent.md). However, starting with SQL Server 2019, you can disable SQLPS. To do so, on the first line of a job step of the type PowerShell you can add, which stops the SQL Agent from autoloading the SQLPS module. When you do this, your SQL Agent Job runs the version of PowerShell installed on the machine, and then you can use any other PowerShell module you like.
66+
There's no change to the module used by SQL Server Agent. As such, SQL Server Agent jobs, which have PowerShell type job steps use the SQLPS module. For more information, see [How to run PowerShell with SQL Server Agent](run-windows-powershell-steps-in-sql-server-agent.md). However, starting with SQL Server 2019, you can disable SQLPS. To do so, on the first line of a job step of the type PowerShell you can add, which stops the SQL Agent from auto-loading the SQLPS module. When you do this, your SQL Agent Job runs the version of PowerShell installed on the machine, and then you can use any other PowerShell module you like.
6167

6268
If you want to use the **SqlServer** module in your SQL Agent Job step, you can place this code on the first two lines of your script.
6369

0 commit comments

Comments
 (0)