Ensure Absent not working

Hi

I’ve been experimenting with DSC to roll out Features on Windows Server. I’m using Windows Server 2012 r2

I have created a configuration which looks like this:

Configuration WebServerFeatures {

Param (
$NodeName
)

Node $NodeName {
        WindowsFeature WebServerIIS {
        Ensure = "Present"
        Name = "Web-Server"
        }    
    }
}

All of the sub features that I want to be installed are all listed in the configuration, so in reality the configuration is much longer than the example listed above.

I don’t want Directory Browsing to be installed, so I have set it to be Absent, eg:

    WindowsFeature DirectoryBrowsing {
        Ensure = "Absent"
        Name = "Web-Dir-Browsing"
    }

I have saved the Configuration as WebServerFeaturesDSC.ps1 in the Modules folder. Then I run it with the following commands:

Set-Location C:\Windows\System32\WindowsPowerShell\v1.0\Modules
. C:\Windows\System32\WindowsPowerShell\v1.0\Modules\WebServerFeaturesDSC.ps1
WebServerFeatures -nodename $($env:computername)

Start-DscConfiguration .\WebServerFeatures -wait -Force

Everything works as expected, except the Directory Browsing feature that I want to be Absent gets installed. When I run Get-DSCConfiguration it lists the feature as present:

Credential           : 
DisplayName          : Directory Browsing
Ensure               : Present
IncludeAllSubFeature : False
LogPath              : 
Name                 : Web-Dir-Browsing
Source               : 
PSComputerName       : 

Can anyone help with this?

Thanks

It’s possible that one of the other higher-level options is defaulting to install directory browsing. The LCM might be removing it, only to have it be re-installed later in the sequence. You could run a trace on the node to see if that’s the case.

I tried running the Start-DscConfiguration command again using -Verbose, and I see that I’m getting an error when it tries to remove the web-dir-browsing feature. Presumably it is being added by one of the higher up features by default, and then it attempts to remove it.

I tried removing it manually from Server Manager and it told me that I had to remove another feature that is dependent on Directory Browsing before I could go ahead. So it looks like that was the issue.