Skip to content

Commit 72e48ea

Browse files
committed
format changes
1 parent a7cc5fe commit 72e48ea

1 file changed

Lines changed: 56 additions & 48 deletions

File tree

docs/powershell/how-to-enable-tcp-sqlps.md

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,80 @@ ms.custom: ""
1212
ms.date: 08/06/2020
1313
---
1414

15-
# How to enable TCP protocol with SQLPS
15+
# How to enable the TCP protocol with SQLPS
1616

1717
How to enable the TCP protocol when connected to the console with SQLPS.
1818

19-
Open a command prompt and type:
19+
1. Open a command prompt and type:
2020

21-
```console
22-
C:\> SQLPS.EXE
23-
```
24-
`Tip: is SQLPS is not found, you may need to open a new command prompt or just log-off
25-
and log back on.`
21+
```console
22+
C:\> SQLPS.EXE
23+
```
2624

27-
At the PowerShell command prompt, type:
25+
> [!TIP]
26+
> If SQLPS is not found, you may need to open a new command prompt or just log-off and log back on.
2827

29-
```powershell
30-
# Instantiate a ManagedComputer object which exposes primitives to control the
31-
# installation of SQL Server on this machine.
32-
$wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' localhost
28+
2. At the PowerShell command prompt, type:
3329

34-
# Enable the TCP protocol on the default instance. If the instance is named,
35-
# replace MSSQLSERVER with the instance name in the following line.
36-
$tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
37-
$tcp.IsEnabled = $true
38-
$tcp.Alter()
30+
```powershell
31+
# Instantiate a ManagedComputer object which exposes primitives to control the
32+
# installation of SQL Server on this machine.
3933

40-
# You need to restart SQL Server for the change to persist
41-
# -Force takes care of any dependent services, like SQL Agent.
42-
# Note: if the instance is named, replace MSSQLSERVER with MSSQL$ followed by
43-
# the name of the instance (e.g. MSSQL$MYINSTANCE)
44-
Restart-Service -Name MSSQLSERVER -Force
45-
```
34+
$wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' localhost
35+
36+
# Enable the TCP protocol on the default instance. If the instance is named,
37+
# replace MSSQLSERVER with the instance name in the following line.
38+
39+
$tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
40+
$tcp.IsEnabled = $true
41+
$tcp.Alter()
42+
43+
# You need to restart SQL Server for the change to persist
44+
# -Force takes care of any dependent services, like SQL Agent.
45+
# Note: if the instance is named, replace MSSQLSERVER with MSSQL$ followed by
46+
# the name of the instance (e.g. MSSQL$MYINSTANCE)
47+
48+
Restart-Service -Name MSSQLSERVER -Force
49+
```
4650

4751
## How to enable the TCP protocol not using SQLPS
4852

49-
How to enable the TCP protocol when connected to the console using PowerShell instead.
53+
How to enable the TCP protocol when connected to the console not using SQLPS.
54+
55+
1. Open a command prompt and type:
56+
57+
```console
58+
C:\> PowerShell.exe
59+
```
60+
61+
2. At the PowerShell command prompt, type:
62+
63+
```powershell
64+
# Get access to SqlWmiManagement DLL on the machine with SQL
65+
# we are on, which is where SQL Server was installed.
66+
# Note: this is installed in the GAC by SQL Server Setup.
5067

51-
Open a command prompt and type:
68+
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SqlWmiManagement')
5269

53-
```console
54-
C:\> PowerShell.exe
55-
```
70+
# Instantiate a ManagedComputer object which exposes primitives to control the
71+
# installation of SQL Server on this machine.
5672

57-
At the PowerShell command prompt, type:
73+
$wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' localhost
5874

59-
```powershell
60-
# Get access to SqlWmiManagement DLL on the machine with SQL
61-
# we are on, which is where SQL Server was installed.
62-
# Note: this is installed in the GAC by SQL Server Setup.
63-
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SqlWmiManagement')
75+
# Enable the TCP protocol on the default instance. If the instance is named,
76+
# replace MSSQLSERVER with the instance name in the following line.
6477

65-
# Instantiate a ManagedComputer object which exposes primitives to control the
66-
# installation of SQL Server on this machine.
67-
$wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' localhost
78+
$tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
79+
$tcp.IsEnabled = $true
80+
$tcp.Alter()
6881

69-
# Enable the TCP protocol on the default instance. If the instance is named,
70-
# replace MSSQLSERVER with the instance name in the following line.
71-
$tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
72-
$tcp.IsEnabled = $true
73-
$tcp.Alter()
82+
# You need to restart SQL Server for the change to persist
83+
# -Force takes care of any dependent services, like SQL Agent.
84+
# Note: if the instance is named, replace MSSQLSERVER with MSSQL$ followed by
85+
# the name of the instance (e.g. MSSQL$MYINSTANCE)
7486

75-
# You need to restart SQL Server for the change to persist
76-
# -Force takes care of any dependent services, like SQL Agent.
77-
# Note: if the instance is named, replace MSSQLSERVER with MSSQL$ followed by
78-
# the name of the instance (e.g. MSSQL$MYINSTANCE)
79-
Restart-Service -Name MSSQLSERVER -Force
80-
```
87+
Restart-Service -Name MSSQLSERVER -Force
88+
```
8189

8290
## Next Steps
8391

0 commit comments

Comments
 (0)