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
This article provides directions for installing the **SqlServer** PowerShell module.
21
+
22
+
## PowerShell modules for SQL Server
23
+
24
+
There are two SQL Server PowerShell modules:
25
+
26
+
-**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).
27
+
-**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.
28
+
29
+
The versions of the **SqlServer** module in the PowerShell Gallery support versioning and require PowerShell version 5.0 or greater.
30
+
31
+
For help topics, go to:
32
+
33
+
- For help topics for the SQL Server PowerShell cmdlets, go to [SqlServer](https://docs.microsoft.com/powershell/module/sqlserver) cmdlets.
34
+
- For help topics for the SQLPS cmdlets, go to [SQLPS](https://docs.microsoft.com/powershell/module/sqlps) cmdlets.
35
+
36
+
## SQL Server Management Studio
37
+
38
+
SQL Server Management Studio (SSMS), beginning with version 17.0, does not include either PowerShell module. To use PowerShell with SSMS, you must install the **SqlServer** module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/Sqlserver).
39
+
19
40
> [!NOTE]
20
-
> There are two SQL Server PowerShell modules:
21
-
> ***SQLPS**: This 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.
22
-
> ***SqlServer**: This module includes new cmdlets to support the latest SQL features. The module also contains updated versions of the cmdlets in **SQLPS**.
41
+
> “With version 16.x of SSMS, an earlier version of the **SqlServer** module is included with SQL Server Management Studio (SSMS)
42
+
43
+
## Installing or updating the SqlServer module
23
44
24
-
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](https://www.powershellgallery.com/packages/Sqlserver).
45
+
To install the **SqlServer** module from the PowerShell Gallery, start a [PowerShell](https://docs.microsoft.com/powershell/scripting/powershell-scripting) session as an administrator.
25
46
26
-
Pre-release versions of the module may become available more frequently: please refer to the section at the bottom of this page on how to get such versions of the module.
47
+
> [!IMPORTANT]
48
+
> If you run into problems installing, see the [Install-Module documentation](https://www.powershellgallery.com/packages/PowerShellGet/2.2.1) and [Install-Module reference](https://docs.microsoft.com/powershell/module/powershellget/Install-Module).
27
49
28
-
To install the **SqlServer** module from the PowerShell Gallery, start a [PowerShell](https://docs.microsoft.com/powershell/scripting/powershell-scripting) session and use the following commands. If you run into problems installing, see the [Install-Module documentation](https://www.powershellgallery.com/packages/PowerShellGet/2.2.1) and [Install-Module reference](https://docs.microsoft.com/powershell/module/powershellget/Install-Module).
50
+
### To install the SqlServer module
29
51
30
-
To install the **SqlServer** module:
52
+
Run the following command in your administrator session to install the SqlServer module for all users.
31
53
32
54
```Install-Module -Name SqlServer```
33
55
34
-
If there are previous versions of the **SqlServer** module on the computer, you may be able to use `Update-Module` (later in this article), or provide the `-AllowClobber` parameter:
56
+
### To overwrite a previous version of the SqlServer module
57
+
58
+
If there are previous versions of the **SqlServer** module on the computer, you may be able to use `Update-Module` (later in this article), or use the `-AllowClobber` parameter:
When updated versions of the **SqlServer** module are available, you can update the version using `Update-Module`:
68
+
### Update the installed version of the SqlServer module
69
+
70
+
When updated versions of the **SqlServer** module are available, update the version using the following command:
43
71
44
72
```Update-Module -Name SqlServer```
45
73
46
-
To view the versions of the module installed:
74
+
### To view the versions of the SqlServer module installed
75
+
76
+
Execute the following command to see the versions of the SqlServer module that have been installed:
47
77
48
78
```Get-Module SqlServer -ListAvailable```
49
79
50
-
To use a specific version of the module, you can import it with a specific version number similar to the following:
80
+
## Using a specific version of the SqlServer module
81
+
82
+
To use a specific version of the module, import it with a specific version number similar to the following command:
51
83
52
84
```Import-Module SqlServer -Version 21.1.18080```
53
85
54
-
> [!NOTE]
55
-
> Prerelease (or "preview") versions of the module may be available on the PowerShell Gallery. They may be discovered and installed
56
-
> by using the updated *Find-Module* and *Install-Module* cmdlets that are part of the [PowerShellGet](https://www.powershellgallery.com/packages/PowerShellGet)
57
-
> module) by passing the *-AllowPrerelease* switch.
58
-
>
59
-
> To discover the prerelease/preview version of the module, you can run the following command:
60
-
>
61
-
> ```Find-Module SqlServer -AllowPrerelease```
62
-
>
63
-
> To install a specific prerelease/preview version of the module, you can install it with a specific version number similar to the following:
## Using pre-release versions of the SqlServer module
87
+
88
+
Pre-release (or "preview") versions of the SqlServer module may be available on the PowerShell Gallery. They may be discovered and installed by using the updated *Find-Module* and *Install-Module* cmdlets that are part of the [PowerShellGet](https://www.powershellgallery.com/packages/PowerShellGet) module by passing the *-AllowPrerelease* switch.
89
+
90
+
### To discover pre-release versions of the SqlServer module
91
+
92
+
To discover the pre-release (preview) versions of the SqlServer module, run the following command:
93
+
94
+
```Find-Module SqlServer -AllowPrerelease```
95
+
96
+
### To install a specific pre-release version of the SqlServer module
97
+
98
+
To install a specific prerelease/preview version of the module, install it with a specific version number similar to the following:
0 commit comments