title: How to create location/ when it doesn't exist in applicationHost.config with Powershell and IISAdministration module
body: <p>Any ideas how to add a new  element to the root of the applicationHost.config using IISAdministration module?</p>
  
  <p>I'd cobbled together the current code (edited for brevity) to bootstrap a new site in IIS 10.</p>
  
  <pre><code>Import-Module IISAdministration
  $Manager = Get-IISServerManager
  $Name = "my.sitedomain.foo"
  $Config = $Manager.GetApplicationHostConfiguration()
  $Config.GetSection("system.webServer/security/dynamicIpSecurity",$Name)
  $DIPSecurity = $Config.GetSection("system.webServer/security/dynamicIpSecurity",$Name)
  if($DIPSecurity -ne $null){
      $DIPSecurity.GetChildElement("denyByRequest") | %{
          $_.SetAttributeValue("enabled",$true)
          $_.SetAttributeValue("maxRequests",20)
          $_.SetAttributeValue("requestIntervalInMilliseconds",200)
      }            
  }
  </code></pre>
  
  <p>When the dynamicIpSecurity element has been modified via IIS Manager then the xml gets added to the config file. Out-of-the-box, however, my IIS applicationHost.config does not have a <code>&lt;location&gt;</code> child element for the site.</p>
  
  <p>The intention is to check if the location element exists and if not, add something like the following</p>
  
  <pre><code>&lt;location path="my.sitedomain.foo"&gt;
      &lt;system.webServer&gt;
          &lt;security&gt;
              &lt;dynamicIpSecurity&gt;
                  &lt;denyByConcurrentRequests enabled="true" /&gt;
                  &lt;denyByRequestRate enabled="true" /&gt;
              &lt;/dynamicIpSecurity&gt;
          &lt;/security&gt;
      &lt;/system.webServer&gt;
  &lt;/location&gt;
  </code></pre>
  
  <p>Many thanks,
  James</p>