@@ -62,7 +62,7 @@ All network protocols are installed during installation, by [!INCLUDE[ssNoVersio
6262 You can run this script from any machine, with or without SQL Server installed. Make sure you have the ** SqlServer** module installed.
6363
6464 ``` powershell
65- #requires the SqlServer module
65+ # This script requires the SqlServer module
6666 Import-Module SQLServer
6767
6868 $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
7676 $Tcp.IsEnabled = $true
7777 $Tcp.Alter()
7878 $Tcp
79-
79+
8080 # Enable the named pipes protocol for the default instance.
8181 $uri = "ManagedComputer[@Name='<#computer_name#>']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']"
8282 $Np = $wmi.GetSmoObject($uri)
@@ -99,22 +99,31 @@ After you enable or disable protocols, you must stop and restart the [!INCLUDE[s
9999
100100``` powershell
101101# Get a reference to the ManagedComputer class.
102- CD SQLSERVER:\SQL\<computer_name>
102+ Set-Location SQLSERVER:\SQL\<computer_name>
103103$Wmi = (get-item .).ManagedComputer
104+
104105# Get a reference to the default instance of the Database Engine.
105106$DfltInstance = $Wmi.Services['MSSQLSERVER']
107+
106108# Display the state of the service.
107109$DfltInstance
110+
108111# Stop the service.
109112$DfltInstance.Stop();
113+
110114# Wait until the service has time to stop.
115+
111116# Refresh the cache.
112117$DfltInstance.Refresh();
118+
113119# Display the state of the service.
114120$DfltInstance
121+
115122# Start the service again.
116123$DfltInstance.Start();
124+
117125# Wait until the service has time to start.
126+
118127# Refresh the cache and display the state of the service.
119128$DfltInstance.Refresh();
120129$DfltInstance
0 commit comments