Join Mike Pfeiffer for an in-depth discussion in this video Managing Windows services, part of Learning Server Core for Windows Server 2012 R2.
- Managing services is a common task for any server administrator and Core is no different. So in Power Shell we do have a set of cmdlets that allow you to manage services. So if you run Get-Command, you can see all of these cmdlets. And we'll just do a Get-Command*-service so a wild card search to show us that we have a get cmdletto retrieve the services. We have a new service command to create services. And we can restart, resume and do all kinds of things with services. So let's take a look and start working with the services. We'll run Get-Service and Power Shell's nature is verb dash singular noun.
And we'll run Get-Service, even though that singular we're still gonna get all the services on the machine. We can run Get-Service against one service to just look at that particular service. And in this case the bits transfer service is stopped. We can use the pipeline to do something like this where we retrieve that service, pipe that over to Start-Service and then when we do another Get-Service on bits obviously that now running. We can also do something like this where we stop the service to reverse that.
And again, now you can see that that service is stopped. Now one of the things that you'll notice is that Get-Service does have a computer name parameter and the machine that I'm on right now is Core 5. So I can run that against the local machine. But if I was on my administrator workstation I could run and get Service - Computer name, specify the server and get back that information. But when it comes to doing things like Start-Service there's no computer name parameter. So I've typed -com and I'm tabbing here and I'm not getting autocomplete because this parameter doesn't exist.
So Start-Service and Stop-Service, they don't have a -computer name parameter and I can't do things remotely with that. But here's what you can do that might help that situation. Let's say that you wanted to manage that bit service on a remote computer. You can store reference to it in a variable such as $s = Get-Service bits on that remote computer name core5 and $s is now a dot net framework object with properties and methods. And we can pipe this object over to Get-Member and look at member types, methods specifically.
And you can see that the service has methods for start and stop. So now that we have a reference to this object on the remote computer we can simply invoke these methods to control the state of the service. So let's clear the screen and type $s and we can actually look at the status, right now it's stopped, and we can say $3.start and invoke that method and if we look locally at the bit service it's now running. And if we go the other direction and stop the service and then look back locally, we can see that it's now stopped.
So that's a high level approach to managing services on your server-core-servers whether you're working locally or remote.
- Understanding the benefits of Server Cover
- Installing Server Core
- Adjusting server settings
- Configuring the Windows firewall
- Managing server roles and features
- Working with files, folders, users, and groups
- Managing services remotely with PowerShell or graphical tools
- Installing updates