Delayed variable expansion of DSC resource

Welcome Forums DSC (Desired State Configuration) Delayed variable expansion of DSC resource

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

 
Participant
3 years, 6 months ago.

  • Author
    Posts
  • #25250

    Participant
    Points: 0
    Rank: Member

    Is there a way to delay the variable expansion of a DSC resource, such as the File resource?

    Example:

    File CopyFile
    {
    SourcePath = $Source
    DestinationPath = "$env:TEMP\File.tmp"
    }

  • #25260

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

    Generally, no. Configuration scripts produce a MOF, which is a static text file. There's no code of any kind in a MOF; everything in the configuration is evaluated when it runs to produce that MOF.

    The exception is a Script resource, which bundles PowerShell code into the MOF to be executed on the node.

  • #25490

    Participant
    Points: 0
    Rank: Member

    I've run in to this type of issue. I wanted resource A to do work and then resource B to do more work based on the output of A. I ended up taking a module from the gallery and augmenting it to discover the right information on the endpoint node rather than taking a parameter.

    Note, the File resource would not be the best candidate for customization, but I do hope to work on xRobocopy as soon as I can make time. 🙂

The topic ‘Delayed variable expansion of DSC resource’ is closed to new replies.