1. Aaron Jensen
  2. Carbon
  3. Issues
Issue #158 resolved

Install-Service - extraneous warning about being unable to stop the service/

James Bennett
created an issue

In a circumstance where $service.CanStop = $false (either set explicitly or because the Service is already stopped), Install-Service will issue the following warning:

Write-Warning "Unable to stop service '$Name' before applying config changes. You may need to restart this service manually for any changes to take affect."

It just needs a little check to see if it is already stopped :)

Also, as suggestion, you have that neat code that shows you the differences between what is currently configured and the current state, ala

if( -not $doInstall )
        {
            if( $failureActions | Where-Object { $_ -eq [Carbon.Service.FailureAction]::Reboot } )
            {
                Write-Verbose ('[{0}] RebootDelay       {1} | {2}' -f $Name,$serviceConfig.RebootDelay,$RebootDelay)
                $doInstall = $serviceConfig.RebootDelay -ne $RebootDelay
            }
        }

if it was re-written as

            if( $failureActions | Where-Object { $_ -eq [Carbon.Service.FailureAction]::Reboot } )
            {
                $doInstall = $serviceConfig.RebootDelay -ne $RebootDelay
                if ($doInstall)
                {
                    Write-Verbose ('[{0}] RebootDelay       {1} | {2}' -f $Name,$serviceConfig.RebootDelay,$RebootDelay)
                }
            }

then you can more easily see exactly which condition originally triggered the need to restart.

Comments (4)

  1. Log in to comment