Script resource looping through configuration items

Welcome Forums DSC (Desired State Configuration) Script resource looping through configuration items

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

2 years, 7 months ago.

  • Author
  • #57181

    Topics: 3
    Replies: 3
    Points: 1
    Rank: Member

    Hello All,

    Using DSC i am trying to set a number of web server properties in IIS.
    I've had a look at the xWebadministration resource and its great and I use it for setting a number of things.
    However, it doesn't look to me like it supports setting a number of things at a server level rather than site level.
    Ok, to get round that i can create a script resource that does a number of Set-webconfigurationProperty things.
    I have 14 things to set. Now i've got it working by breaking it up into multiple script resources, for example,

    Script IIS_1 {
    		GetScript = {
    						GetScript = $GetScript
    						SetScript = $SetScript
    						TestScript = $TestScript
    						Result = (Get-WebConfigurationProperty /system.applicationhost/confighistory -name path.value)
    		setScript = {
    		Set-WebConfigurationProperty /system.applicationhost/confighistory -name path -value "d:\inetpub\history"
    		Testscript = {
    			(Get-WebConfigurationProperty /system.applicationhost/confighistory -name path.value) -eq "d:\inetpub\history"

    Now i can set the next property by creating a new script resource and just copying the above but replacing the configuration property.
    However, i think there must be a better way of achieving this by just looping through each webconfigurationproperty and checking and setting where appropriate. I am struggling though to see how this can be done


  • #57533

    Topics: 13
    Replies: 4872
    Points: 1,813
    Helping HandTeam Member
    Rank: Community Hero

    You're to the point where you should be writing a custom resource, rather than using Script. You're simply running up against the limitations of what Script was designed to do.

    • #57631

      Topics: 3
      Replies: 3
      Points: 1
      Rank: Member

      Thanks Don,

      yes i can see that now, I have actually got the functionality I want working, which was the first step.
      I've dont this by repeating the script resource for each property i want to set.
      The next step is to now create a custom resource and streamline it all a bit.


The topic ‘Script resource looping through configuration items’ is closed to new replies.