I’ve started testing WMF 5 Production Preview against my DSC config that works perfectly with WMF 5 April Preview. To cut a long story short I can no longer apply partial DSC config to a node. Any one of the following errors can appear:
The resource PSDesiredStateConfiguration from module MSFT_FileDirectoryConfiguration is imported twice using
version 1.0 and version 0.0. Using more than one version of a resource is not supported. Remove one of the
versions to correct the problem.
The resource PSDesiredStateConfiguration from module MSFT_RoleResource is imported twice using version 0.0 and version 1.0. Using more than one version of a resource is not supported. Remove one of the versions to correct the problem.
The resource PSDesiredStateConfiguration from module MSFT_ScriptResource is imported twice using version 0.0 and version 1.0. Using more than one
version of a resource is not supported. Remove one of the versions to correct the problem.
I’ve created some proof of concept code to show how the error can be generated.
--------- LCMConfig.ps1 snip -------------
[DSCLocalConfigurationManager()]
Configuration LCMConfig
{
param
(
[Parameter(Mandatory = $True)]
[string]$ComputerName,
[Parameter(Mandatory = $True)]
[string]$PullServer,
[Parameter(Mandatory = $True)]
[string]$GUID
)
Node $ComputerName {
Settings {
RefreshMode = "Pull"
ConfigurationID = $GUID
RebootNodeIfNeeded = $True
}
ConfigurationRepositoryWeb DSCHTTP {
ServerURL = "http://$($PullServer):8080/PSDSCPullServer.svc"
AllowUnsecureConnection = $True
}
PartialConfiguration PartConfig1
{
Description = 'Test description'
ConfigurationSource = '[ConfigurationRepositoryWeb]DSCHTTP'
}
PartialConfiguration PartConfig2
{
Description = 'Test description'
ConfigurationSource = '[ConfigurationRepositoryWeb]DSCHTTP'
DependsOn = '[PartialConfiguration]PartConfig1'
}
}
}
--------- LCMConfig.ps1 snip -------------
--------- PartConfig.ps1 snip -------------
configuration PartConfig1
{
Import-DscResource –ModuleName PSDesiredStateConfiguration
node ("PartConfig1.$GUID")
{
File FriendlyName1
{
Ensure = 'Present'
DestinationPath = 'C:\PartConfig1.txt'
Type = 'File'
}
}
}
configuration PartConfig2
{
Import-DscResource –ModuleName PSDesiredStateConfiguration
node ("PartConfig2.$GUID")
{
File FriendlyName2
{
Ensure = 'Present'
DestinationPath = 'C:\PartConfig2.txt'
Type = 'File'
}
Script WDSAnswerPolicy {
PsDscRunAsCredential = $Credential
GetScript = {
@{
GetScript = $GetScript
SetScript = $SetScript
TestScript = $TestScript
Result = $True
}
}
SetScript = {
# Do nothing
}
TestScript = {
$True
}
}
}
}
--------- PartConfig.ps1 snip -------------
--------- Run.ps1 snip -------------
$Node = ‘MyTestNode’
$PullServer = ‘MyTestPullServer’
$GUID = ‘b32e5e76-fe9f-4fef-8d58-9ff9d3a268d3’
$MOFDestPath = ‘C:\Program Files\WindowsPowerShell\DscService\Configuration’
Import Functions
. “$PSScriptRoot\LCMConfig.ps1”
. “$PSScriptRoot\PartConfig.ps1”
Generate MOF files
$MOFFile = PartConfig1 -OutputPath $MOFDestPath
New-DscChecksum -Path “$MOFDestPath$MODFile” -Force
$MOFFile = PartConfig2 -OutputPath $MOFDestPath
New-DscChecksum -Path “$MOFDestPath$MODFile” -Force
Generate Meta MOF file
LCMConfig -ComputerName $Node -PullServer $PullServer -GUID $GUID -OutputPath “$PSScriptRoot\Temp”
Send Meta MOF config to Node
Set-DscLocalConfigurationManager -ComputerName $Node -Path “$PSScriptRoot\Temp” -Verbose
Update Configuation
Update-DscConfiguration -ComputerName $Node -Wait -Verbose
--------- Run.ps1 snip -------------