Author Posts

June 17, 2015 at 6:15 pm

I have created a custom resource 'SyncShare' and I can get it to run with expected results if I copy the resource folder to the modulepath on the target node. However, if I try to combine copying that resource to the target and applying it in a single configuration ( see below), the LCM on the target says that the resource isn't in the psmodulepath –despite the fact that I have used the 'DependsOn' property to ensure that the directory exists. In fact, the custom resource is not respecting the dependsOn property at all, since I find that it is always being evaluated before the file resource that would make that resource available. See this configuration fragment:

File Resource_SyncShare
{
Type = "Directory"
DestinationPath = $Node.ResourceRootPath+"\SyncShare"
SourcePath = $Node.ResourceSourcePath+"\SyncShare"
Ensure = "Present"
MatchSource = $True
Recurse = $True
Force = $True
Credential = $Credential
Checksum = "modifiedDate"
}

SyncShare Tools
{
Name = "Tools"
SourceDirectory = $Node.ToolsDirSourcePath
DestinationDirectory = $Node.ToolsDirDestinationPath
ChecksumFileName = "sync.checksum"
Ensure = "Present"
DependsOn = "[File]Resource_SyncShare"
}

June 17, 2015 at 6:55 pm

The LCM is probably reading the whole file and making sure that the resources exist before it starts to actually execute anything. You won't be able to distribute the resources that way.

If you're using a pull server, don't worry about it, as the resources will be downloaded from there on an as-needed basis. If you're using Push deployments, then you'll need to copy out the necessary resources just before you execute Start-DscConfiguration.

In PowerShell v5, you can do a hybrid of the two, where a pull server is used to download resources, but you can still apply configurations with a push via Start-DscConfiguration.

June 17, 2015 at 7:11 pm

Correct: the LCM pre-scans the file to make sure it has every resource needed before it processes anything. And, as Dave notes, it'll then grab modules from a pull server, if so configured. So you can't use a config to file-copy a resource AND use that resource. This is essentially what a pull server is meant to help solve.

June 18, 2015 at 10:15 am

Thanks for the reply. I'm going to wait on setting up a pull server in prod until WMF5 is in GA.