# Delayed variable expansion of DSC resource

**URL:** <https://forums.powershell.org/t/delayed-variable-expansion-of-dsc-resource/4197>\
**Category:** DSC\
**Created:** [May 14, 2015, 1:19pm UTC](https://forums.powershell.org/t/delayed-variable-expansion-of-dsc-resource/4197 "2015-05-14T13:19:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam-weigert](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/adam-weigert/32/982_2.png) [@adam-weigert](https://forums.powershell.org/u/adam-weigert)\
**Post date:** [May 14, 2015, 1:19pm UTC](https://forums.powershell.org/t/delayed-variable-expansion-of-dsc-resource/4197/1 "2015-05-14T13:19:21Z")

</div>

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”
}
`

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [May 14, 2015, 10:59pm UTC](https://forums.powershell.org/t/delayed-variable-expansion-of-dsc-resource/4197/2 "2015-05-14T22:59:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![michael-greene](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/michael-greene/32/337_2.png) [@michael-greene](https://forums.powershell.org/u/michael-greene)\
**Post date:** [May 20, 2015, 12:42pm UTC](https://forums.powershell.org/t/delayed-variable-expansion-of-dsc-resource/4197/3 "2015-05-20T12:42:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:17pm UTC](https://forums.powershell.org/t/delayed-variable-expansion-of-dsc-resource/4197/4 "2024-05-16T21:17:19Z")

</div>


