Bagikan melalui


Using the Restart-Service Cmdlet

Stopping and Restarting a Service

The Restart-Service cmdlet is designed to stop and then restart the specified service. (If the service is already stopped, well, that’s OK: in that case Restart-Service will simply start the service.) This is a particularly useful cmdlet for services that have memory leaks and periodically need to be stopped and then restarted; Restart-Service can take care of both of those functions with a single command.

To use Restart-Service simply call the cmdlet followed by the service name:

Restart-Service btwdins

To restart multiple services just specify the name of each service, separated by commas:

Restart-Service btwdins,alerter

If you prefer, add the -displayname parameter and specify the service display name (the name shown in the Services snap-in) instead:

Restart-Service -displayname "bluetooth service"