1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

This commit is contained in:
Simon Liddicott 2017-08-06 23:14:56 +01:00 committed by Jordan Borean
parent 0343ac1a9d
commit 3ceeb5124e

View file

@ -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."
}