DSC tries to start service I set to manual, and errors out on it

This topic contains 5 replies, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 4 months, 3 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #38846
    Profile photo of Bill Farrell
    Bill Farrell
    Participant

    I have the following DSC resource:

    Service sacsvrManual {
    Name='sacsvr'
    StartupType='Manual'
    }

    Notice that there is no State mentioned. But when it runs, I get the following, indicating it tested it and decided that it needed to be RUNNING:

    VERBOSE: [MTS1020]: LCM: [ Start Resource ] [[Service]sacsvrManual]
    VERBOSE: [MTS1020]: LCM: [ Start Test ] [[Service]sacsvrManual]
    VERBOSE: [MTS1020]: LCM: [ End Test ] [[Service]sacsvrManual] in 0.0160 seconds.
    VERBOSE: [MTS1020]: LCM: [ Start Set ] [[Service]sacsvrManual]
    VERBOSE: [MTS1020]: [[Service]sacsvrManual] Service 'sacsvr' already exists. Write properties such as Status, DisplayName,
    Description, Dependencies will be ignored for existing services.
    VERBOSE: [MTS1020]: LCM: [ End Set ] [[Service]sacsvrManual] in 2.5780 seconds.
    PowerShell DSC resource MSFT_ServiceResource failed to execute Set-TargetResource functionality with error message: Failure starting service
    'sacsvr'. Please check the path 'C:\Windows\System32\svchost.exe -k netsvcs' provided for the service. Message: 'Exception calling "WaitForStatus"
    with "2" argument(s): "Time out has expired and the operation has not been completed."'
    + CategoryInfo : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName : MTS1021

    I can't figure out why it is deciding to start the service.

    #38858
    Profile photo of Don Jones
    Don Jones
    Keymaster

    The Service resource is probably defaulting the State property.

    What's the goal? To ensure that the service is set to Manual but not care if it's currently running or not?

    #38876
    Profile photo of Bill Farrell
    Bill Farrell
    Participant

    Exactly. Set it to manual but leave its state in place.

    #38881
    Profile photo of Don Jones
    Don Jones
    Keymaster

    I'd probably just do this with a custom resource, or even a quick Script resource. Get-Service and Set-Service can obviously do that easily.

    #38895
    Profile photo of Bill Farrell
    Bill Farrell
    Participant

    Thanks Don, that has occurred to me, but with the number of services I'm setting to manual, I'm thinking of combining them into a single script resource and just have it run every time. It's too cumbersome to do a script for each service.

    By the way, I checked the MOF that was generated, and there was nothing about State in it; powershell correctly generated the MOF as far as I can tell, it seems like something the LCM is doing.

    #38898
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Well, keep in mind that the point of DSC is for each resource to be idempotent. Id you want, just knock out a quick DSC resource module that can set a service's start mode only, and then call that for each service.

    It wouldn't be the LCM doing it. The LCM doesn't do anything but run resources; have a look at the Service resource – it's what's doing the work.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.