{"action":"created","comment":{"url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/comments/31731837","id":31731837,"diff_hunk":"@@ -0,0 +1,160 @@\n+######################################################################################\n+# DSC Resource for IIS Server level Feature Delegation\n+######################################################################################\n+\n+data LocalizedData\n+{\n+    # culture=\"en-US\"\n+    ConvertFrom-StringData @'\n+NoWebAdministrationModule=Please ensure that WebAdministration module is installed.\n+UnableToGetConfig=Unable to get configuration data for '{0}'\n+ConfigNotFound=No configuration data found for '{0}'\n+ChangedMessage=Changed overrideMode for '{0}' to {1}\n+'@\n+}\n+\n+######################################################################################\n+# The Get-TargetResource cmdlet.\n+# This function will get the Mime type for a file extension\n+######################################################################################\n+function Get-TargetResource\n+{\n+  [OutputType([Hashtable])]\n+\tparam\n+\t(\t\t\n+\t\t[Parameter(Mandatory)]\n+\t\t[ValidateNotNullOrEmpty()]\n+\t\t[String]$SectionName,\n+\n+\t\t[Parameter(Mandatory)]\n+\t\t[ValidateNotNullOrEmpty()]\n+        [ValidateSet(\"Allow\", \"Deny\")]\n+        [String]$OverrideMode\n+\t)\n+\t\n+    CheckIISPoshModule\n+\n+    $getTargetResourceResult = $null;\n+\n+    [string]$oMode = GetOverrideMode $SectionName\n+\n+    if ($oMode -eq $null)\n+    {\n+        $ensureResult = \"Absent\";\n+    }\n+    else\n+    {\n+        $ensureResult = \"Present\"\n+        $getTargetResourceResult = @{SectionName = $SectionName\n+                                    OverrideMode = $oMode}\n+    }\n+\n+    \n+\treturn $getTargetResourceResult\n+}\n+\n+######################################################################################\n+# The Set-TargetResource cmdlet.\n+# This function set the OverrideMode for a given section if not already correct\n+######################################################################################\n+function Set-TargetResource\n+{\n+\tparam\n+\t(\t\n+\t\t[Parameter(Mandatory)]\n+\t\t[ValidateNotNullOrEmpty()]\n+\t\t[String]$SectionName,\n+\n+\t\t[Parameter(Mandatory)]\n+\t\t[ValidateNotNullOrEmpty()]\n+        [ValidateSet(\"Allow\", \"Deny\")]\n+        [String]$OverrideMode\n+    )\n+\n+    CheckIISPoshModule\n+    [string]$oMode = GetOverrideMode $SectionName\n+\n+\n+    if ($oMode -eq \"Allow\" -and $OverrideMode -eq \"Deny\")\n+    {\n+         Set-webconfiguration -Location \"\" -Filter \"/system.webServer/$SectionName\" -PSPath \"machine/webroot/apphost\" -metadata overrideMode -value Deny\n+         Write-Verbose($($LocalizedData.ChangedMessage) -f $SectionName,\"Deny\")\n+    }\n+    elseif ($oMode -eq \"Deny\" -and $OverrideMode -eq \"Allow\")\n+    {\n+         Set-webconfiguration -Location \"\" -Filter \"/system.webServer/$SectionName\" -PSPath \"machine/webroot/apphost\" -metadata overrideMode -value Allow\n+         Write-Verbose($($LocalizedData.ChangedMessage) -f $SectionName,\"Allow\")\n+    }\n+}\n+\n+######################################################################################\n+# The Test-TargetResource cmdlet.\n+# This will test if the given section has the required OverrideMode\n+######################################################################################\n+function Test-TargetResource\n+{\n+    [OutputType([System.Boolean])]\n+\tparam\n+\t(\t\n+\t\t[Parameter(Mandatory)]\n+\t\t[ValidateNotNullOrEmpty()]\n+\t\t[String]$SectionName,\n+\n+\t\t[Parameter(Mandatory)]\n+\t\t[ValidateNotNullOrEmpty()]\n+        [ValidateSet(\"Allow\", \"Deny\")]\n+        [String]$OverrideMode\n+\t)\n+\n+    CheckIISPoshModule\n+\n+    [bool]$DesiredConfigurationMatch = $true;\n+    [string]$oMode = GetOverrideMode $SectionName\n+\n+    if ($oMode -eq $OverrideMode)\n+    {\n+        $DesiredConfigurationMatch = $true;\n+    }\n+    elseif ($oMode -ne $null -and $OverrideMode -ne $oMode)\n+    {\n+        $DesiredConfigurationMatch = $false;\n+    }\n+    else\n+    {\n+        Write-Verbose($($LocalizedData.ConfigNotFound) -f $SectionName)\n+        $DesiredConfigurationMatch = $false;\n+    }\n+        \n+\treturn $DesiredConfigurationMatch\n+}\n+\n+Function CheckIISPoshModule\n+{\n+    # Check if WebAdministration module is present for IIS cmdlets\n+    if(!(Get-Module -ListAvailable -Name WebAdministration))\n+    {\n+        Throw $LocalizedData.NoWebAdministrationModule\n+    }\n+}\n+\n+Function GetOverrideMode([string]$section)\n+{\n+    $errorMessage = $($LocalizedData.UnableToGetConfig) -f $section\n+    if ((get-webconfiguration -Location \"\" -Filter /system.webServer/$section).count -eq 0)\n+    {        \n+        Throw $errorMessage;\n+    }\n+\n+    [string]$oMode = ((get-webconfiguration -Location \"\" -Filter /system.webServer/$section -metadata).Metadata).effectiveOverrideMode\n+\n+    # check for a single value.\n+    if ($oMode -notmatch \"^(Allow|Deny)$\")\n+    {\n+        Throw $errorMessage","path":"DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.psm1","position":153,"original_position":153,"commit_id":"c8718c14c7b484216c2fc8430b585d6e8d475658","original_commit_id":"c8718c14c7b484216c2fc8430b585d6e8d475658","user":{"login":"hahndorf","id":778685,"avatar_url":"https://avatars.githubusercontent.com/u/778685?v=3","gravatar_id":"","url":"https://api.github.com/users/hahndorf","html_url":"https://github.com/hahndorf","followers_url":"https://api.github.com/users/hahndorf/followers","following_url":"https://api.github.com/users/hahndorf/following{/other_user}","gists_url":"https://api.github.com/users/hahndorf/gists{/gist_id}","starred_url":"https://api.github.com/users/hahndorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hahndorf/subscriptions","organizations_url":"https://api.github.com/users/hahndorf/orgs","repos_url":"https://api.github.com/users/hahndorf/repos","events_url":"https://api.github.com/users/hahndorf/events{/privacy}","received_events_url":"https://api.github.com/users/hahndorf/received_events","type":"User","site_admin":false},"body":"I added the check because at some point `$oMode` had a value of `Allow Allow` because I got my XPath wrong and returned multiple nodes. It shouldn't happen anymore, but I thought I can't hurt and kept it in there.","created_at":"2015-06-04T15:29:31Z","updated_at":"2015-06-04T15:29:31Z","html_url":"https://github.com/PowerShell/xWebAdministration/pull/23#discussion_r31731837","pull_request_url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/comments/31731837"},"html":{"href":"https://github.com/PowerShell/xWebAdministration/pull/23#discussion_r31731837"},"pull_request":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23","id":36936649,"html_url":"https://github.com/PowerShell/xWebAdministration/pull/23","diff_url":"https://github.com/PowerShell/xWebAdministration/pull/23.diff","patch_url":"https://github.com/PowerShell/xWebAdministration/pull/23.patch","issue_url":"https://api.github.com/repos/PowerShell/xWebAdministration/issues/23","number":23,"state":"open","locked":false,"title":"4 new server level resources","user":{"login":"hahndorf","id":778685,"avatar_url":"https://avatars.githubusercontent.com/u/778685?v=3","gravatar_id":"","url":"https://api.github.com/users/hahndorf","html_url":"https://github.com/hahndorf","followers_url":"https://api.github.com/users/hahndorf/followers","following_url":"https://api.github.com/users/hahndorf/following{/other_user}","gists_url":"https://api.github.com/users/hahndorf/gists{/gist_id}","starred_url":"https://api.github.com/users/hahndorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hahndorf/subscriptions","organizations_url":"https://api.github.com/users/hahndorf/orgs","repos_url":"https://api.github.com/users/hahndorf/repos","events_url":"https://api.github.com/users/hahndorf/events{/privacy}","received_events_url":"https://api.github.com/users/hahndorf/received_events","type":"User","site_admin":false},"body":"I created 4 new resources: **xIisFeatureDelegation, xIisMimeTypeMapping, xWebAppPoolDefaults, xWebSiteDefaults**\r\n\r\nThey all apply changes on the IIS server level and they are by no means covering all settings, but it is a start.\r\n\r\nI've done some examples and tests, which are all integration tests that change the actual system but then role back. I'm not sure how to mock these things.\r\n\r\nThese are my first DSC resources, so please review and critique them.","created_at":"2015-06-04T13:59:09Z","updated_at":"2015-06-04T15:29:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8944d25bb5ca25cec2d9ce47b235721faf3a8cfc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23/commits","review_comments_url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23/comments","review_comment_url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PowerShell/xWebAdministration/issues/23/comments","statuses_url":"https://api.github.com/repos/PowerShell/xWebAdministration/statuses/c8718c14c7b484216c2fc8430b585d6e8d475658","head":{"label":"hahndorf:ServerLevelResources","ref":"ServerLevelResources","sha":"c8718c14c7b484216c2fc8430b585d6e8d475658","user":{"login":"hahndorf","id":778685,"avatar_url":"https://avatars.githubusercontent.com/u/778685?v=3","gravatar_id":"","url":"https://api.github.com/users/hahndorf","html_url":"https://github.com/hahndorf","followers_url":"https://api.github.com/users/hahndorf/followers","following_url":"https://api.github.com/users/hahndorf/following{/other_user}","gists_url":"https://api.github.com/users/hahndorf/gists{/gist_id}","starred_url":"https://api.github.com/users/hahndorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hahndorf/subscriptions","organizations_url":"https://api.github.com/users/hahndorf/orgs","repos_url":"https://api.github.com/users/hahndorf/repos","events_url":"https://api.github.com/users/hahndorf/events{/privacy}","received_events_url":"https://api.github.com/users/hahndorf/received_events","type":"User","site_admin":false},"repo":{"id":36596330,"name":"xWebAdministration","full_name":"hahndorf/xWebAdministration","owner":{"login":"hahndorf","id":778685,"avatar_url":"https://avatars.githubusercontent.com/u/778685?v=3","gravatar_id":"","url":"https://api.github.com/users/hahndorf","html_url":"https://github.com/hahndorf","followers_url":"https://api.github.com/users/hahndorf/followers","following_url":"https://api.github.com/users/hahndorf/following{/other_user}","gists_url":"https://api.github.com/users/hahndorf/gists{/gist_id}","starred_url":"https://api.github.com/users/hahndorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hahndorf/subscriptions","organizations_url":"https://api.github.com/users/hahndorf/orgs","repos_url":"https://api.github.com/users/hahndorf/repos","events_url":"https://api.github.com/users/hahndorf/events{/privacy}","received_events_url":"https://api.github.com/users/hahndorf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hahndorf/xWebAdministration","description":"My fork of IIS DSC module for adding new resources","fork":true,"url":"https://api.github.com/repos/hahndorf/xWebAdministration","forks_url":"https://api.github.com/repos/hahndorf/xWebAdministration/forks","keys_url":"https://api.github.com/repos/hahndorf/xWebAdministration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hahndorf/xWebAdministration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hahndorf/xWebAdministration/teams","hooks_url":"https://api.github.com/repos/hahndorf/xWebAdministration/hooks","issue_events_url":"https://api.github.com/repos/hahndorf/xWebAdministration/issues/events{/number}","events_url":"https://api.github.com/repos/hahndorf/xWebAdministration/events","assignees_url":"https://api.github.com/repos/hahndorf/xWebAdministration/assignees{/user}","branches_url":"https://api.github.com/repos/hahndorf/xWebAdministration/branches{/branch}","tags_url":"https://api.github.com/repos/hahndorf/xWebAdministration/tags","blobs_url":"https://api.github.com/repos/hahndorf/xWebAdministration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hahndorf/xWebAdministration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hahndorf/xWebAdministration/git/refs{/sha}","trees_url":"https://api.github.com/repos/hahndorf/xWebAdministration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hahndorf/xWebAdministration/statuses/{sha}","languages_url":"https://api.github.com/repos/hahndorf/xWebAdministration/languages","stargazers_url":"https://api.github.com/repos/hahndorf/xWebAdministration/stargazers","contributors_url":"https://api.github.com/repos/hahndorf/xWebAdministration/contributors","subscribers_url":"https://api.github.com/repos/hahndorf/xWebAdministration/subscribers","subscription_url":"https://api.github.com/repos/hahndorf/xWebAdministration/subscription","commits_url":"https://api.github.com/repos/hahndorf/xWebAdministration/commits{/sha}","git_commits_url":"https://api.github.com/repos/hahndorf/xWebAdministration/git/commits{/sha}","comments_url":"https://api.github.com/repos/hahndorf/xWebAdministration/comments{/number}","issue_comment_url":"https://api.github.com/repos/hahndorf/xWebAdministration/issues/comments{/number}","contents_url":"https://api.github.com/repos/hahndorf/xWebAdministration/contents/{+path}","compare_url":"https://api.github.com/repos/hahndorf/xWebAdministration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hahndorf/xWebAdministration/merges","archive_url":"https://api.github.com/repos/hahndorf/xWebAdministration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hahndorf/xWebAdministration/downloads","issues_url":"https://api.github.com/repos/hahndorf/xWebAdministration/issues{/number}","pulls_url":"https://api.github.com/repos/hahndorf/xWebAdministration/pulls{/number}","milestones_url":"https://api.github.com/repos/hahndorf/xWebAdministration/milestones{/number}","notifications_url":"https://api.github.com/repos/hahndorf/xWebAdministration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hahndorf/xWebAdministration/labels{/name}","releases_url":"https://api.github.com/repos/hahndorf/xWebAdministration/releases{/id}","created_at":"2015-05-31T09:30:39Z","updated_at":"2015-05-31T09:31:31Z","pushed_at":"2015-06-04T11:30:51Z","git_url":"git://github.com/hahndorf/xWebAdministration.git","ssh_url":"git@github.com:hahndorf/xWebAdministration.git","clone_url":"https://github.com/hahndorf/xWebAdministration.git","svn_url":"https://github.com/hahndorf/xWebAdministration","homepage":"","size":396,"stargazers_count":0,"watchers_count":0,"language":"PowerShell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"PowerShell:dev","ref":"dev","sha":"ef3b635b161ed874e82b526a6e66e0f77ff39150","user":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars.githubusercontent.com/u/11524380?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"repo":{"id":34022265,"name":"xWebAdministration","full_name":"PowerShell/xWebAdministration","owner":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars.githubusercontent.com/u/11524380?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PowerShell/xWebAdministration","description":null,"fork":false,"url":"https://api.github.com/repos/PowerShell/xWebAdministration","forks_url":"https://api.github.com/repos/PowerShell/xWebAdministration/forks","keys_url":"https://api.github.com/repos/PowerShell/xWebAdministration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PowerShell/xWebAdministration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PowerShell/xWebAdministration/teams","hooks_url":"https://api.github.com/repos/PowerShell/xWebAdministration/hooks","issue_events_url":"https://api.github.com/repos/PowerShell/xWebAdministration/issues/events{/number}","events_url":"https://api.github.com/repos/PowerShell/xWebAdministration/events","assignees_url":"https://api.github.com/repos/PowerShell/xWebAdministration/assignees{/user}","branches_url":"https://api.github.com/repos/PowerShell/xWebAdministration/branches{/branch}","tags_url":"https://api.github.com/repos/PowerShell/xWebAdministration/tags","blobs_url":"https://api.github.com/repos/PowerShell/xWebAdministration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PowerShell/xWebAdministration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PowerShell/xWebAdministration/git/refs{/sha}","trees_url":"https://api.github.com/repos/PowerShell/xWebAdministration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PowerShell/xWebAdministration/statuses/{sha}","languages_url":"https://api.github.com/repos/PowerShell/xWebAdministration/languages","stargazers_url":"https://api.github.com/repos/PowerShell/xWebAdministration/stargazers","contributors_url":"https://api.github.com/repos/PowerShell/xWebAdministration/contributors","subscribers_url":"https://api.github.com/repos/PowerShell/xWebAdministration/subscribers","subscription_url":"https://api.github.com/repos/PowerShell/xWebAdministration/subscription","commits_url":"https://api.github.com/repos/PowerShell/xWebAdministration/commits{/sha}","git_commits_url":"https://api.github.com/repos/PowerShell/xWebAdministration/git/commits{/sha}","comments_url":"https://api.github.com/repos/PowerShell/xWebAdministration/comments{/number}","issue_comment_url":"https://api.github.com/repos/PowerShell/xWebAdministration/issues/comments{/number}","contents_url":"https://api.github.com/repos/PowerShell/xWebAdministration/contents/{+path}","compare_url":"https://api.github.com/repos/PowerShell/xWebAdministration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PowerShell/xWebAdministration/merges","archive_url":"https://api.github.com/repos/PowerShell/xWebAdministration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PowerShell/xWebAdministration/downloads","issues_url":"https://api.github.com/repos/PowerShell/xWebAdministration/issues{/number}","pulls_url":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls{/number}","milestones_url":"https://api.github.com/repos/PowerShell/xWebAdministration/milestones{/number}","notifications_url":"https://api.github.com/repos/PowerShell/xWebAdministration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PowerShell/xWebAdministration/labels{/name}","releases_url":"https://api.github.com/repos/PowerShell/xWebAdministration/releases{/id}","created_at":"2015-04-15T22:43:09Z","updated_at":"2015-05-21T18:20:53Z","pushed_at":"2015-06-04T13:59:09Z","git_url":"git://github.com/PowerShell/xWebAdministration.git","ssh_url":"git@github.com:PowerShell/xWebAdministration.git","clone_url":"https://github.com/PowerShell/xWebAdministration.git","svn_url":"https://github.com/PowerShell/xWebAdministration","homepage":null,"size":396,"stargazers_count":2,"watchers_count":2,"language":"PowerShell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":12,"forks":14,"open_issues":12,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23"},"html":{"href":"https://github.com/PowerShell/xWebAdministration/pull/23"},"issue":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/issues/23"},"comments":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/PowerShell/xWebAdministration/statuses/c8718c14c7b484216c2fc8430b585d6e8d475658"}}}}