5

I found an error in the Archive DSC module (MSFT_ArchiveResource.psm1). After copying the code, debugging it in the ISE and figuring out the two lines that needed to be fixed, I want to make the change to the real file and test using Puppet and the msutter/dsc module, which makes use of the Archive Resource.

I found where I thought was the location of the file on my machine:

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\DSCResources\MSFT_ArchiveResource\MSFT_ArchiveResource.psm1

However, when I run Puppet, it is clear that my changed code is not being exercised. (If I set $Debug = $true at the top of the file, I do not see the extra output.) Is there some Windows cache that holds this file that I must clear? Is it being loaded from a ZIP or other archive?

I doubt that Puppet is related to the issue, but mention it in case it rings a bell. (I only made the code change on the Agent.)

UPDATE:

When I run the following line in Powershell, I do not find any process with the expected name containing "dsccore":

Get-WmiObject msft_providers | select -ExpandProperty provider

Results:

RegistryEventProvider
PolicyAgentInstanceProvider
CIMWin32
Msft_ProviderSubSystem
SCM Event Provider
Win32_WIN32_TERMINALSERVICE_Prov
WmiPerfClass
WmiPerfClass
WmiPerfInst
WmiPerfInst
Paul Chernoch
  • 5,275
  • 3
  • 52
  • 73

2 Answers2

5

Troubleshooting DSC

My resources won’t update: How to reset the cache

The DSC engine caches resources implemented as a PowerShell module for efficiency purposes. However, this can cause problems when you are authoring a resource and testing it simultaneously because DSC will load the cached version until the process is restarted. The only way to make DSC load the newer version is to explicitly kill the process hosting the DSC engine.

To identify which process is hosting the DSC engine and stop it on a per instance basis, you can list the process ID of the WmiPrvSE which is hosting the DSC engine. Then, to update the provider, stop the WmiPrvSE process using the commands below, and then run Start-DscConfiguration again.

###
### find the process that is hosting the DSC engine
###
$dscProcessID = Get-WmiObject msft_providers | 
Where-Object {$_.provider -like 'dsccore'} | 
Select-Object -ExpandProperty HostProcessIdentifier 

###
### Stop the process
###
Get-Process -Id $dscProcessID | Stop-Process
briantist
  • 45,546
  • 6
  • 82
  • 127
  • The advice you give I found on this page: https://technet.microsoft.com/en-us/library/dn249926.aspx – Paul Chernoch Apr 22 '15 at 16:12
  • Yes, I linked it already (click the Troubleshooting DSC header in my answer), and that's why I used the quote tags. – briantist Apr 22 '15 at 16:14
  • When I execute the first line, I get no process Id returned. I do see many WmiPrvSE.exe processes in Task Manager, but do not know which is for DSC. – Paul Chernoch Apr 22 '15 at 16:28
  • The only thing that worked was rebooting the computer. I was hoping to find a solution that executes fast and does not require a reboot. – Paul Chernoch Apr 22 '15 at 19:14
0

In WMF 5.0 DSC added the option to force import the modules without killing the process. It is documented on MSDN here.

Here is an example of how to enable it:

configuration settings
{
    LocalConfigurationManager
    {
        DebugMode = 'ForceModuleImport'
    }
}

$outputPath = "$env:temp\lcmSettings"

settings -outputPath $outputPath
Set-DscLocalConfigurationManager -Path $outputPath -Force -Verbose
TravisEz13
  • 2,263
  • 1
  • 20
  • 28