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.
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
Subreddit
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...