Ensure Absent not working

Welcome Forums DSC (Desired State Configuration) Ensure Absent not working

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #73463

    Participant
    Topics: 1
    Replies: 1
    Points: 0
    Rank: Member

    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

  • #73468

    Keymaster
    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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.

  • #73570

    Participant
    Topics: 1
    Replies: 1
    Points: 0
    Rank: Member

    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.

The topic ‘Ensure Absent not working’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort