Databases Reference
In-Depth Information
You could also use the Stop - Service cmdlet with the -confirm parameter directly, as shown here (see
Figure 7-12):
Stop-Service -Displayname *sql* -Confirm
Figure 7-12
Start-Service
Instead of using the methods from Get-Service to start a service, you could use the cmdlet
Start-Service .
Now try to start a stopped SQL Server Agent service. The following example will try to start the
SQLAgent$SQL2008 service (see Figure 7-13):
Start-Service -Name SQLAgent`$SQL2008
Get-Service -Name SQLAgent`$SQL2008
PowerShell assumes that anything prefixed with the dollar sign ($) is a variable. The backtick sign (`) is
used to escape the $ sign.
Figure 7-13
Now use the following to find all the SQL server-related services that are not started (see Figure 7-14):
Get-Service -DisplayName *sql* | Where-Object {$_.Status -eq "Stopped"}
Search WWH ::




Custom Search