Does the Powershell command Restart-Service -force restart dependent services?

This could be my shortest post ever, with a simple “yes”, but let me elaborate.

At times, you have to restart a service. With Powershell, this is easy enough (provided you have the right permissions): Restart-Service -name will do the trick. But every now and again, you have to restart a service that has dependent services. Like WMI, or SQL Server.  In that case, Powershell will raise an error:

PowerShell service restart error

PowerShell service restart error

For those who actually read error messages, this one is pretty clear: you have to use the -Force flag to restart a service with dependent services (actually only one in this case, but who’s counting?). But does that also restart the dependent services? The Services MMC does restart dependent services, but I don’t like guessing. Let’s find out.

The first place to look is in the help: Help Restart-Service -Full.

Force switch

Force switch


No answer here. So let’s test it. I’ll use the SQL Server service as an example, which has one dependent service: the SQL Server Agent service.First, let’s find out what the dependent service actually is. Get-service returns a service object with a property called Dependentservices; expanding that returns the required info.

Now, let’s restart SQL Server:

Now, the service will be restarted. You can hit the up arrow twice, and rerun the command to check the status of the dependent services. And there’s you’re answer: the dependent services are restarted as well.

This entry was posted in Powershell, Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *