How can I Restart-service
remotely with WinRM, without a yes/no confirmation on a remote computer in a workgroup?
Asked
Active
Viewed 4,118 times
-2

Clashsoft
- 11,553
- 5
- 40
- 79

michel vaillancourt
- 59
- 2
- 5
-
1Please, show at least one line of code you have tried ? – sodawillow Nov 22 '15 at 11:42
-
Have you tried `Invoke-Command` with a `-ComputerName` parameter, and the `-Force` and `-Confirm` parameters for `Restart-Service` ? – sodawillow Nov 22 '15 at 12:43
1 Answers
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