Kill pending windows service

Get-Service winrm -Verbose
$winrmService=Get-CimInstance -ClassName win32_Service |? {$_.Name -eq "winrm"}
$id=$winrmService.ProcessId
$status=$winrmService.State
if(($id -ne 0) -and ($status -ne "Running"))
{
   "it will kill winrm process"
    kill -Id $id -Force -Verbose
    winrm qc -q
}
Get-Service winrm -Verbose
posted @ 2020-01-06 21:37  talentzemin  阅读(171)  评论(0编辑  收藏  举报