Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

6
Powershell and IIS - Setting WebDAV rules
Post Flair (click to view more posts with a particular flair)
Post Body

EDIT: I've filed a bug report for this on Microsoft's Uservoice here: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/16809403-bug-add-webconfigurationproperty-does-not-correct

EDIT2: Posted here instead: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/17044378-bug-add-webconfigurationproperty-does-not-correct (the first one I posted is in the IIS section, which seems to be abandoned).

EDIT3: Scratch that, they closed the second report. Apparently IIS cmdlet problems must go in the IIS uservoice, even if it is seemingly abandoned. Report is here: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/16809403-bug-add-webconfigurationproperty-does-not-correct

Alright, I have a solid half day into this, and can't get it work quite right. Some of the IIS cmdlets feel very.. un-powershell. I'd consider myself pretty damned decent with PS, and this is baffling me. Help me /r/PowerShell!

SETUP:

  • Server 2012 R2
  • IIS installed with WebDAV Publishing (this is located under IIS -> Web Server -> Common HTTP Features)
  • Two virtual directories set up under the default website:
    • TestShare2
    • TestShare3

These virtual directories are being set up via PowerShell like this:

$shareName = 'TestShare2'
$createdFolder = New-Item -Path "C:\sharetest\$shareName" -ItemType Directory
New-WebVirtualDirectory -Name $shareName -PhysicalPath $createdFolder.FullName -Site 'Default Web Site'

GOALS:

  • Set WebDAV authoring rule on the two virtual directories to the following settings
    • Users - *
    • Path - *
    • Access - Read, Write, Source
  • It should look like this in the GUI
  • It should look like this in the configuration file (which is located at C:\Windows\System32\Inetsrv\Config\applicationHost.config):

    <location path="Default Web Site/TestShare2">
        <system.webServer>
            <webdav>
                <authoringRules>
                    <add users="*" path="*" access="Read, Write, Source" />
                </authoringRules>
            </webdav>
        </system.webServer>
    </location>
    

WHAT I'M GETTING:

  • This is what I'm seeing in the GUI (just read access)
  • This is what I'm seeing in the configuration file:

    <location path="Default Web Site/TestShare3">
        <system.webServer>
            <webdav>
                <authoringRules>
                    <add users="*" path="*" /> (** NOTE MISSING "access" PROPERTY **)
                </authoringRules>
            </webdav>
        </system.webServer>
    </location>
    

For some reason, it's not including the "access" portion of the configuration, and I have no idea why.


WHAT I'M TRYING TO USE:

Documentation on some of these IIS cmdlets is a bit lacking, but this is what I've gathered:

$filter = '/system.webServer/webdav/authoringRules' 
$location = 'Default Web Site/TestShare3'
$accessRule = @{
  users  = '*'
  path   = '*'
  access = 'Read, Write, Source'
}

Add-WebConfigurationProperty -Filter $filter -Location $location -Name '.' -Value $accessRule -Verbose

EDIT - NON-POWERSHELL SOLUTION

Well, I worked with the guys in the PowerShell slack/IRC, and none of us could get this to work. The general consensus is that there is a bug in the IIS module.

I ended up doing this via appcmd:

appcmd.exe set config "Default Web Site/TestShare3" -section:system.webServer/webdav/authoringRules / "[roles='*',path='*',access='Read, Write, Source']" /commit:apphost

Author
Account Strength
100%
Account Age
14 years
Verified Email
Yes
Verified Flair
No
Total Karma
13,842
Link Karma
1,262
Comment Karma
12,572
Profile updated: 11 hours ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago