Starting and Stopping a service with the use of the right cmdlets

We have already talked about the get-service cmdlet in the previous post. Now let’s talked about two other similar cmdlets.

First, lets use the cmdlet get-service to check our services.

Cmdlet get-service gets all the available services in our computer.
(click on the image to open in a new tab)

We can manipulate these services with the right cmdlets.

We use the DisplayName property to isolate the service we are interested with. Let’s say this service is the fontcache service.

In the status column we notice that the service is running.
(click on the image to open in a new tab)

We see that this service is running!

Stopping a service

What about stopping it?

Could we achieve that with a cmdlet?

Yes! There is the stop-service cmdlet, that is suitable for this job.

Let’s see if we can stop it.

The stop-service cmdlet, stops the service.
(click on the image to open in a new tab)

We notice that we still need to use the get-service cmdlet in order to check the status of the service.

Get-service does exactly that, display a service to powershell, while stop-service is stopping it behind the scenes without displaying it.

NOTE: In order to save typing you can use the Tab + arrowUp/arrowDown shortcut that enables us to get past cmdlets showing.

Starting a service

There is cmdlet for that.

It’s easy to guess. We just type start-service and we are good.

We can start an innactive service with the start-service cmdlet.
(click on the image to open in a new tab)

Here we also need the get-service cmdlet in order to display what’s going on.

The start-service cmdlet can only start the service, not display it.

This is consistent with the basic principle of all Cmdlets. Do one specific thing only.

Although my blog doesn’t support comments, feel free to reply via email or X.

Privacy Policy Lambros Hatzinikolaou © 2024 — Today. All rights reserved.