In IIS, the physical path credentials are set in applicationHost.config like so:
<virtualDirectory path="/" physicalPath="C:\Path\to\files" userName="user" password="[enc:IISCngProvider:ENCRYPTEDBLOBHERE=:enc]" />
To set or change the value of userName and password, I can use Set-WebConfigurationProperty:
$xpath = "system.applicationhost/sites/site[@name='Default Web Site']/application[@path='/MyApplication']/virtualDirectory[@path='/']"
Set-WebConfigurationProperty $xpath -name userName -value "USERNAME"
Set-WebConfigurationProperty $xpath -name password -value "PASSWORD"
But how do I remove those attributes, so IIS switches back to using pass-through authentication? I've tried all of the following with no success:
Remove-WebConfigurationProperty $xpath -name userName
# Property name userName doesn't point to collection.
Remove-WebConfigurationProperty "$xpath/@userName"
# The Name parameter is required
Remove-WebConfigurationProperty "$xpath/@userName" -name .
# WARNING: Property . is not found on /system.applicationHost/sites/site[@name='Default Web Site' and @id='1']/application[@path='/MyApplication']/virtualDirectory[@path='/']/@userName.
Clear-WebConfiguration "$xpath/@userName" -Force
# Nothing appears to change
Remove-ItemProperty "IIS:\Sites\Default Web Site\MyApplication" -Name userName
# Property name userName doesn't point to collection.
I know I can do this with appcmd, but shouldn't there be a way to do this with the WebAdministration module?