How do I reference environment variable in specific Resource Provider?

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Justin King Justin King 8 months ago.

  • Author
    Posts
  • #37571
    Profile photo of GS
    GS
    Participant

    Hello,

    I'm trying to use Package provider and it has LogPath parameter, I'd like it to be pointing to $env:Temp variable. If I use it straight up on my authoring machine then it's obviously expands this variable into local MOF file and hence it will fail in production.
    So how do I instruct MOF file to use $env:Temp on machine MOF destined to be used on?

  • #37573
    Profile photo of Justin King
    Justin King
    Participant

    I *think* you're asking how to setup a mof so it effectively contains a variable (in this case $env:temp) and thus pulls the correct value dynamically on the target machine and doesn't actually pass the $env:temp on your authoring machine.

    So I've only found two ways t do this personally:

    1. I ensure the module that will be generating these logs defaults to $env:temp so I don't have to define it in my configuration. Sometimes it means a slight tweak, but that's the joy of the modules being so accessible.

    2. I use the script resource to do said work. This way I can use setscript and it can contain whatever environment variables I want ... it all runs on the client anyway.

    https://msdn.microsoft.com/en-us/powershell/dsc/scriptResource

    I'm not aware of how to deliver a mof that contains variables outside of setscript. I've been proven wrong before, however, so I'm interested to see how others might handle this.

You must be logged in to reply to this topic.