PowerShell can help not only audit your current instance configurations, but can also help if you need to manage and change configurations, such as changing service accounts and default backup folders and turning on (or off) some instance- and database-level features.
There are a handful cmdlets that work with services. To get these cmdlets, you can use the following command:
Get-Command -Name "*Service*" -CommandType "Cmdlet"
The result you will get is similar to the following screenshot:
To start or stop services, you can use the Start-Service
and Stop-Service
cmdlets. The following snippet is an example of how you can use these cmdlets. In the following example, we are targeting the SQL Server Agent service of a named instance called SQL2014
. This service can be referred to as SQLAgent$SQL2014
. Since the $
sign is a special character in PowerShell that signifies variable names, the $
sign in the service name needs to be escaped with a backtick...