@@ -62,7 +62,7 @@ All network protocols are installed during installation, by [!INCLUDE[ssNoVersio
62
62
You can run this script from any machine, with or without SQL Server installed. Make sure you have the ** SqlServer** module installed.
63
63
64
64
``` powershell
65
- #requires the SqlServer module
65
+ # This script requires the SqlServer module
66
66
Import-Module SQLServer
67
67
68
68
$wmi = New-Object Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer <#computer_name#>
@@ -76,7 +76,7 @@ All network protocols are installed during installation, by [!INCLUDE[ssNoVersio
76
76
$Tcp.IsEnabled = $true
77
77
$Tcp.Alter()
78
78
$Tcp
79
-
79
+
80
80
# Enable the named pipes protocol for the default instance.
81
81
$uri = "ManagedComputer[@Name='<#computer_name#>']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']"
82
82
$Np = $wmi.GetSmoObject($uri)
@@ -99,22 +99,31 @@ After you enable or disable protocols, you must stop and restart the [!INCLUDE[s
99
99
100
100
``` powershell
101
101
# Get a reference to the ManagedComputer class.
102
- CD SQLSERVER:\SQL\<computer_name>
102
+ Set-Location SQLSERVER:\SQL\<computer_name>
103
103
$Wmi = (get-item .).ManagedComputer
104
+
104
105
# Get a reference to the default instance of the Database Engine.
105
106
$DfltInstance = $Wmi.Services['MSSQLSERVER']
107
+
106
108
# Display the state of the service.
107
109
$DfltInstance
110
+
108
111
# Stop the service.
109
112
$DfltInstance.Stop();
113
+
110
114
# Wait until the service has time to stop.
115
+
111
116
# Refresh the cache.
112
117
$DfltInstance.Refresh();
118
+
113
119
# Display the state of the service.
114
120
$DfltInstance
121
+
115
122
# Start the service again.
116
123
$DfltInstance.Start();
124
+
117
125
# Wait until the service has time to start.
126
+
118
127
# Refresh the cache and display the state of the service.
119
128
$DfltInstance.Refresh();
120
129
$DfltInstance
0 commit comments