-2

How can I Restart-service remotely with WinRM, without a yes/no confirmation on a remote computer in a workgroup?

Clashsoft
  • 11,553
  • 5
  • 40
  • 79

1 Answers1

1

You can use WMI:

$ServiceName = 'Spooler'
$WMI = Get-WmiObject win32_service -Filter "name='$ServiceName'" -ComputerName $computer
$WMI.StopService()
$WMI.StartService()
Avshalom
  • 8,657
  • 1
  • 25
  • 43