Set startup type to automatic before attempting to start the service. Otherwise it will fail if the service is disabled. (#27751)

pull/27335/head
Simon Liddicott 7 years ago committed by Jordan Borean
parent 0343ac1a9d
commit 3ceeb5124e

@ -171,12 +171,12 @@ If (!(Get-Service "WinRM"))
}
ElseIf ((Get-Service "WinRM").Status -ne "Running")
{
Write-Verbose "Starting WinRM service."
Start-Service -Name "WinRM" -ErrorAction Stop
Write-Log "Started WinRM service."
Write-Verbose "Setting WinRM service to start automatically on boot."
Set-Service -Name "WinRM" -StartupType Automatic
Write-Log "Set WinRM service to start automatically on boot."
Write-Verbose "Starting WinRM service."
Start-Service -Name "WinRM" -ErrorAction Stop
Write-Log "Started WinRM service."
}

Loading…
Cancel
Save