Script resource looping through configuration items

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of veroli veroli 2 weeks, 5 days ago.

  • Author
    Posts
  • #57181
    Profile photo of veroli
    veroli
    Participant

    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

    regards
    Dan

  • #57533
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
      Profile photo of veroli
      veroli
      Participant

      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.

      thanks
      dan

You must be logged in to reply to this topic.