Using a Custom class 5 DSCresource multiple times in a Configuration

Welcome Forums DSC (Desired State Configuration) Using a Custom class 5 DSCresource multiple times in a Configuration

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 years, 3 months ago.

  • Author
    Posts
  • #53894

    Participant
    Points: 1
    Rank: Member

    Hi

    Using Server 2012R2 with WMF 5
    I have written a DSCresource in Class 5 style for installing SharePoint 2013 updates.

    When I try to compile-to-mof using this dscresource in my configuration mutliple times for deploying different patches I get errors like the following:

    Test-ConflictingResources : A conflict was detected between resources '[InstallSharePointUpdate]SharePointSP1 (::441::9::InstallSharePointUpdate)' and '[InstallSharePointUpdate]SharePointSP1LanguagePackUpdate (::451::9::InstallSharePointUpdate)' in node 'vm11'. Resources have identical key properties but there are differences in the following non-key properties: 'PatchFileName'. Values 'officeserversp2013-kb2880552-fullfile-x64-en-us.exe' don't match values 'serverlpksp2013-kb2880554-fullfile-x64-nb-no.exe'. Please upd
    ate these property values so that they are identical in both cases.
    At line:271 char:9
    +         Test-ConflictingResources $keywordName $canonicalizedValue $k ...
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Write-Error], InvalidOperationException
        + FullyQualifiedErrorId : ConflictingDuplicateResource,Test-ConflictingResources
    Test-ConflictingResources : A conflict was detected between resources '[InstallSharePointUpdate]SharePointSP1 (::441::9::InstallSharePointUpdate)' and '[InstallSharePointUpdate]SharePointAprilCU2016 (::461::9::InstallSharePointUpdate)' in node 'vm11'. Resou
    rces have identical key properties but there are differences in the following non-key properties: 'PatchFileName'. Values 'officeserversp2013-kb2880552-fullfile-x64-en-us.exe' don't match values 'ubersrv2013-kb3114938-fullfile-x64-glb.exe'. Please update these proper
    ty values so that they are identical in both cases.
    At line:271 char:9 

    In the Configuration they look like this:

    # Install SharePoint 2013 SP 1
            InstallSharePointUpdate SharePointSP1
            {
                PathtoFile = $ConfigurationData.NonNodeData.SharePoint.Binaries.Updates
                PatchFileName = 'officeserversp2013-kb2880552-fullfile-x64-en-us.exe'
                Ensure = "Present"
                PsDscRunAsCredential = $SPSetupCred  
                DependsOn = "[InstallSharePointLanguagePack]NoLAnguagePack"      
            }
     
            # Install Norwegian Language pack for SharePoint 2013 SP 1
            InstallSharePointUpdate SharePointSP1LanguagePackUpdate
            {
                PathtoFile = $ConfigurationData.NonNodeData.SharePoint.Binaries.Updates
                PatchFileName = 'serverlpksp2013-kb2880554-fullfile-x64-nb-no.exe'
                Ensure = "Present"          
                PsDscRunAsCredential = $SPSetupCred   
                DependsOn = "[InstallSharePointUpdate]SharePointSP1"     
            }
     
            # Install SharePoint 2013 CU April 2016
            InstallSharePointUpdate SharePointAprilCU2016
            {
                PathtoFile = $ConfigurationData.NonNodeData.SharePoint.Binaries.Updates
                PatchFileName = 'ubersrv2013-kb3114938-fullfile-x64-glb.exe'
                Ensure = "Present"          
                PsDscRunAsCredential = $SPSetupCred   
                DependsOn = "[InstallSharePointUpdate]SharePointSP1LanguagePackUpdate"     
            } 

    How can i change this dscresource so that it will let me reuse it installing different patches?

    What does work is creating dupicate classes with new names and running one update per dscresource. But that seems like waste of space:P..

    Any tips are welcome!

    Brgs

    Bjørn

  • #53901

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    In your class-based resource, what property have you defined as the key?

    Your class needs to be designed so that every instance of it in a configuration can have a unique key. That isn't the case, which is why PowerShell's upset.

  • #53960

    Participant
    Points: 1
    Rank: Member

    Hi Don,

    Thank you that worked nicely!

    Brgs

    Bjørn

The topic ‘Using a Custom class 5 DSCresource multiple times in a Configuration’ is closed to new replies.