Windows Service installation task error

Hello, I recently started getting an error on one of my installation steps for a Windows Service.

I have a lifecycle where it deploys to my local dev machine and then automatically deploys to a test server after it successfully deploys there. It succeeds in the dev machine deployment but started failing on the test machine with the following error below.

I can see in the services manager that the service was installed correctly since the service points to the new deployed path of the service, but it has not started.

The error below is from the Octopus.Features.WindowsService_BeforePostDeploy.ps1 task

Get-WmiObject : Call cancelled
Error 16:18:58
At C:\Program Files\Octopus Deploy\Tentacle\Scripts\Octopus.Features.WindowsSer
Error 16:18:58
vice_BeforePostDeploy.ps1:124 char:24
Error 16:18:58

  • $status = Get-WMIObject <<<< win32_service -filter (“name=’” + $serviceName
    Error 16:18:58
  • “’”) -computer “.” | select -expand startMode
    Error 16:18:58
    • CategoryInfo : InvalidOperation: (:slight_smile: [Get-WmiObject], Managemen
      Error 16:18:58
      tException
      Error 16:18:58
    • FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
      Error 16:18:58
      ommands.GetWmiObjectCommand
      Info 16:18:58
      The OrbitNotification service already exists. It will be stopped and reconfigured.
      Stopping the OrbitNotification service
      sc.exe config OrbitNotification binPath= “C:\Octopus\Applications\Test\Orbit.Service\2.4.0.311_1\Orbit.Service.exe” DisplayName= “EASO - Orbit” depend= / start= auto obj= tiburon-domain\svc_pmo_dbtest password= “************”
      [SC] ChangeServiceConfig SUCCESS
      Updating the service description
      [SC] ChangeServiceConfig2 SUCCESS
      Fatal 16:18:58
      PowerShell script returned a non-zero exit code: 1
      Tentacle version 2.6.0.778

The agent on the machine is also running as the LocalSystem account

Hi Joey,

On your test machine, could you please check the Octopus.Features.WindowsService_BeforePostDeploy.ps1 file in C:\Program Files\Octopus Deploy\Tentacle\Scripts on line 124 as from the error message below, it looks like some invalid characters (<<<<) have made into that line, see below:

+ $status = Get-WMIObject <<<< win32_service -filter ("name='" + $serviceName
+ "'") -computer "." | select -expand startMode

Hope that helps!

Thank you and warm regards,
Henrik

Here is what is on line 124 on that server in the scripts folder:

$status = Get-WMIObject win32_service -filter (“name=’” + $serviceName + “’”) -computer “.” | select -expand startMode

I also ran a diff with p4merge against another server’s WindowsService_BeforePostDeploy.ps1 file and there were no differences.

I figured this out myself.

I just restarted the Windows Management Service (winmgmt) and it started working again.

The fact that line (get-wmiobject) was failing only on this machine and not others led me down the path of restarting it.

Hope this helps others!