Depends on with variable name

Welcome Forums DSC (Desired State Configuration) Depends on with variable name

Viewing 2 reply threads
  • Author
    Posts
    • #185306
      Participant
      Topics: 2
      Replies: 5
      Points: 60
      Rank: Member

      Hi,

      I am trying to Powershell configuration in which I have an array of websites.

      As I will have multiple websites, I will need to create first a new directory for the respective website, and then create the IIS website and application pool. Here is an example:

      I need that DependsOn just to be sure that the website in IIS is created after the directory is created on the disk. When I try to compile this MOF, I get the following error:

      ValidateNodeResources : Resource ‘[File]System.Collections.Hashtable.Name’ required by
      ‘[xWebsite]SiteName’ does not exist. Please ensure that the required resource exists and the
      name is properly formed.

      How is the correct way to define the DependsOn when it is a variable? If I use DependsOn with a string [File]CreateDirectory then it works, but I can’t use a static string because on top of this configuration it is a foreach which creates the directory on disc, website, apppool for each website, so they have to be unique.

      Thank you

    • #185906
      Participant
      Topics: 0
      Replies: 24
      Points: 158
      Helping Hand
      Rank: Participant

      Try using:

      DependsOn = @("[File]$($Site.Name)",[otherdependencies with variables])

    • #187180
      Participant
      Topics: 2
      Replies: 5
      Points: 60
      Rank: Member

      Thank you,

      I figured it out eventually, but my post was approved very late 🙂

      Appreciate the help.

Viewing 2 reply threads
  • The topic ‘Depends on with variable name’ is closed to new replies.