How do I resolve "Cannot invoke the SendConfigurationApply method." when performing Start-DscConfiguration?
Asked Answered
D

2

14

Another way to phrase the question less specifically: What is the correct way to 'reset' the DSC processes on a target machine?

I've created a DSC configuration that I'm iterating on right now, and I am adding new Package configuration which I've gotten wrong. I determined that by forgetting to supply the /quiet argument to an MSI installer in a Package block I can cause the Start-DscConfiguration cmdlet to 'hang'.

At the onset of this 'hang' I stop the DSC configuration operation on my local machine and attempt to correct the configuration problem (by adding the /quiet argument in my example) then I restart the DSC operation. Now I am seeing the following for my remote machines during the operation:

Cannot invoke the SendConfigurationApply method. The PerformRequiredConfigurationChecks method is in progress and must return before SendConfigurationApply can be invoked.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : REMOTEMACHINE20

Unfortunately, visiting the remote PC being configured I see a similar error message, and rebooting the PC doesn't seem to rectify the error.

I've seen some posts online regarding this problem, and the three I've found thus far suggest:

  1. "Just wait a while and it will resolve itself", which hasn't worked for me (maybe I'm impatient...). Not a tenable long-term solution.
  2. "Delete all local .mof files and try again", which hasn't worked for me either.
  3. Stop all processes with 'wmi' in the name and restart the winrm service on the target machine(s). This has gotten me unblocked, but I am hopeful there is a better way to do this. (If I don't hear a better method in the next few days I'll answer this myself with this procedure to get the results required).
Dispart answered 16/9, 2014 at 19:39 Comment(1)
I had the same problem, and solution 3 is the one I found which worked for me as well. None of the others did.Fannyfanon
U
4

You could also try executing the start-dscconfiguration command with the -Force option

Start-DscConfiguration -Force ...
Unwitting answered 18/2, 2015 at 21:45 Comment(1)
Since I posted this original question, I have done a lot of learning on DSC. This is indeed the correct answer for this issue. When did the -Force switch show up? (Doesn't matter, but it would be good to have it here for posterity going forward).Dispart
M
21

I've found the following works pretty well to reset DSC. Note this will delete the local configuration, so you will need to re-apply the machinename.meta.mof file.

#Remove all mof files (pending,current,backup,MetaConfig.mof,caches,etc)
rm C:\windows\system32\Configuration\*.mof*
#Kill the LCM/DSC processes
gps wmi* | ? {$_.modules.ModuleName -like "*DSC*"} | stop-process -force

At this point you have a clean system ready to be configured using Set-DscLocalConfigurationManager and updated using Update-DscConfiguration -Wait -Verbose -CimSession machinename

So far the only thing this hasn't fixed is a corrupted $env:psmodulepath or missing scheduled tasks for Consistency/Reboot checks. Update: According to this item on connect the scheduled tasks for Consistency/Reboot were removed in the WMF 5.0 February preview.

Marijane answered 27/3, 2015 at 0:50 Comment(2)
Thanks, after 2 hours pulling my hair out, your answer finally got DSC working again.Exotoxin
An alternative to removing all MOF files is to use Remove-DscConfigurationDocument -Stage Pending -Force. This will remove a hung configuration that is in progress. Also, I had to kill all processes prior to removal as it didn't let me remove the document without killing the processes.Ridden
U
4

You could also try executing the start-dscconfiguration command with the -Force option

Start-DscConfiguration -Force ...
Unwitting answered 18/2, 2015 at 21:45 Comment(1)
Since I posted this original question, I have done a lot of learning on DSC. This is indeed the correct answer for this issue. When did the -Force switch show up? (Doesn't matter, but it would be good to have it here for posterity going forward).Dispart

© 2022 - 2024 — McMap. All rights reserved.