1

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?

6
  • 1
    The reason it isn't work is because your syntax isn't correct. Restart-Service 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
    Commented Jul 8, 2016 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? Commented Jul 8, 2016 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" Commented Jul 8, 2016 at 15:00
  • 1
    It is worth pointing out that netmon or Network Monitor does not even appear to be a service but an executable.
    – Ramhound
    Commented Jul 8, 2016 at 15:04
  • 2
    @Ramhound Looking at TechNet for powershell 1.0: "Using the Restart-Service Cmdlet", three's no mention of it. Looking at TechNet for PS v5: "Restart-Service" 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. Commented Jul 8, 2016 at 15:05

1 Answer 1

2

First of all - your Service Same doesn't always match the Service Display Name. In this example - I would need to Restart-Service vds:

enter image description here

If you want to get a full service list and look at the service name, you can do a simple Get-Service: enter image description here

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

(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: enter image description here 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": enter image description here

By Elevating, these commands will start to work again: enter image description here 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: enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .