Im using powershell, as Administrator in windows8.1.
I give the command Restart-Service netmon but it fails with no service found.
ok, how do I restart netmon then?
- 1,418
- 5
- 18
- 27
-
1The reason it isn't work is because your syntax isn't correct. [Restart-Service](https://technet.microsoft.com/en-us/library/hh849823.aspx?f=255&MSPPError=-2147217396) You should have used `Restart-Service -Name netmon` instead. You will need to be sure you use the name of an actual service that exists, your syntax as provide in your question, is incorrect though. – Ramhound Jul 08 '16 at 14:58
-
"Netmon" is not a standard Windows 8.1 service, so this is something you've added (or a typo?). So, is their actually a "Netmon" service on that computer? If you run `sc query netmon` from a command prompt, does it report that a service with that name is installed? – Ƭᴇcʜιᴇ007 Jul 08 '16 at 14:58
-
1@Ramhound the "-name" qualifier is unneeded when there are no ambiguous arguments. MS's basic instructions for using the command say "To use Restart-Service simply call the cmdlet followed by the service name: `Restart-Service btwdins`" – Ƭᴇcʜιᴇ007 Jul 08 '16 at 15:00
-
@Ƭᴇcʜιᴇ007 - Every example in the documention on the cmdlet uses the `-Name` qualifier though – Ramhound Jul 08 '16 at 15:02
-
1It is worth pointing out that `netmon` or [Network Monitor](https://www.microsoft.com/en-us/download/details.aspx?id=4865) does not even appear to be a service but an executable. – Ramhound Jul 08 '16 at 15:04
-
2@Ramhound Looking at TechNet for powershell 1.0: ["Using the Restart-Service Cmdlet"](https://technet.microsoft.com/en-us/library/ee176942.aspx), three's no mention of it. Looking at TechNet for PS v5: ["Restart-Service"](https://technet.microsoft.com/en-us/library/hh849823.aspx) lists the "default parameters" showing the `-Name` qualifier as optional (it's in square brackets in the docs). My point is tho is simply that the OPs syntax is correct. :) I think we're on the same page tho -- the OP is just referencing an invalid service, as the error message told him. – Ƭᴇcʜιᴇ007 Jul 08 '16 at 15:05
1 Answers
First of all - your Service Same doesn't always match the Service Display Name. In this example - I would need to Restart-Service vds:
If you want to get a full service list and look at the service name, you can do a simple Get-Service:

You could then narrow this down using a "Where" clause similar to this Get-Service | Where {$_.Name -like "Net*"}:

(Or you could just find your service in services.msc or you could use sc query)
When you have your actual service name, you can then restart, stop, start or query the service:
Stop-Service | Start-Service | Restart-Service | Get-Service
Sometimes you will get a service error stating that the service isnt installed on your machine. Normally this is because you aren't running "As Admistrator":

By Elevating, these commands will start to work again:
The error message isn't very good for this - and I've seen it trip people up before several times.
Edit - just re-read your question and seen you say you are running as Admin already. Are you able to post a screenshot for us please? Or confirm it by running the following:
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”)){
Write-Warning “You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!”
}
If your session has been properly elevated, you won't get the warning as shown in the below screenshot:

- 12,520
- 1
- 36
- 48
