2

I was trying to restart winRM services in multiple servers, but am getting below error can I get suggestions.

Restart-Service -ComputerName (Get-Content G:\12282019\Servers.txt) -ServiceName WinRM

error:

Restart-Service : A parameter cannot be found that matches parameter name 'ComputerName'. At line:1 char:17 + restart-service -ComputerName (Get-Content G:\12282019\Servers.txt) - ... + ~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Restart-Service], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.RestartServiceCommand

I.T Delinquent
  • 2,305
  • 2
  • 16
  • 33
Prasanth K S
  • 63
  • 1
  • 2
  • 7

1 Answers1

4

Restart-Service doesn't have a ComputerName parameter - See here for the Microsoft document. The easiest option would be:

Get-Service -ComputerName HOST_NAME -Name WinRM | Restart-Service

Here is an article that goes into more depth

I.T Delinquent
  • 2,305
  • 2
  • 16
  • 33