You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/powershell/download-sql-server-ps-module.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ ms.technology: scripting
5
5
ms.topic: conceptual
6
6
author: markingmyname
7
7
ms.author: maghan
8
-
ms.reviewer: carlrab
8
+
ms.reviewer: matteot, aanelson
9
9
ms.custom: ""
10
10
ms.date: 06/10/2020
11
11
---
@@ -21,7 +21,8 @@ This article provides directions for installing the **SqlServer** PowerShell mod
21
21
There are two SQL Server PowerShell modules:
22
22
23
23
-**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.
25
26
26
27
> [!NOTE]
27
28
> 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
48
49
49
50
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.
50
51
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
+
51
54
### Install the SqlServer module
52
55
53
56
Run the following command in your PowerShell session to install the SqlServer module for all users:
Copy file name to clipboardExpand all lines: docs/powershell/sql-server-powershell.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,17 +29,23 @@ To install the **SqlServer** module, see [Install SQL Server PowerShell](downloa
29
29
30
30
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.
31
31
32
-
**Update your PowerShell scripts if they import the SQLPS module.**
32
+
**Update your PowerShell scripts if you import the SQLPS module.**
33
33
34
34
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.
35
35
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
+
36
40
## SQL Server PowerShell Components
37
41
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.
39
45
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.
41
47
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.
43
49
44
50
## SQL Server Versions
45
51
@@ -57,7 +63,7 @@ Query expressions are strings that use syntax similar to XPath to specify a set
57
63
58
64
## SQL Server Agent
59
65
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.
61
67
62
68
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.
0 commit comments