Delayed variable expansion of DSC resource

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Michael Greene Michael Greene 1 year, 5 months ago.

  • Author
  • #25250
    Profile photo of Adam Weigert
    Adam Weigert

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


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

  • #25260
    Profile photo of Don Jones
    Don Jones

    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
    Profile photo of Michael Greene
    Michael Greene

    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. 🙂

You must be logged in to reply to this topic.