How do I use WindowsFeatureSet?

Welcome Forums DSC (Desired State Configuration) How do I use WindowsFeatureSet?

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

GS
 
Participant
2 years, 5 months ago.

  • Author
    Posts
  • #38598
    GS

    Participant
    Points: 0
    Rank: Member

    Not understanding what am I doing wrong but I can not run following configuration, it keeps asking me to enter Name parameter

    Configuration dd
    {
        WindowsFeatureSet DefaultIIS {
    	    Name = 'FileAndStorage-Services'
        } 
    }
    dd 
    

    Result is

    cmdlet WindowsFeatureSet at command pipeline position 1
    Supply values for the following parameters:
    Name[0]: 
    
  • #38606

    Participant
    Points: 0
    Rank: Member

    Two things that come to mind:

    1. Please add the Ensure='Present' inside the WindowsFeatureSet

    2. Add a Node localhost wrapping the WindowsFeatureSet

  • #38607
    GS

    Participant
    Points: 0
    Rank: Member

    Ensure is optional and Node did not help either, still fails.

  • #38619

    Participant
    Points: 0
    Rank: Member

    Based on the github repo for when these new cmdlets were added

    https://github.com/PowerShell/PowerShell-Docs/commit/49fca7d7f788efe3457208e982dd0bd6d4ade441

    And the "vastly" number of examples around, the WindowsFeatureSet is used to enable certain set items of the Windows Feature, so lets say in FileAndStorage-Services you would have a set item called NFS and you only want to install that part, I think you need to use it as such:

    Configuration DD
    {
       WindowsFeatureSet FileAndStorage-Services
       {
          Name = NFS
       }
    
    
    }
    DD
    

    As I cant test it myself at the moment, I leave that part to you 😉

  • #38623
    GS

    Participant
    Points: 0
    Rank: Member

    That's exactly what I have which is failing.

  • #38625

    Participant
    Points: 0
    Rank: Member

    The script I wrote isn't the one you posted in the initial question, so I'm puzzled which script you really have.

  • #38626
    GS

    Participant
    Points: 0
    Rank: Member

    May be I'm missing something but the only thing different I see is name of featureset is different and Name property is different bit syntax and use exactly the same

  • #38628

    Participant
    Points: 0
    Rank: Member

    You have to use the syntax and words I used, name of the feature set has to be that value. As for the Name property inside, you need to put the name of the set you want, NFS was just an invention as I dont know exactly what's inside that windows feature

  • #38630
    GS

    Participant
    Points: 0
    Rank: Member

    Solution was to including Import-DSCResource as well as specify "Ensure" parameter, despite the fact in Syntax help it's showing as "optional", it's actually required. Also all string parameters needs to be enclosed in Quotes.

    Configuration dd
    {
    import-dscresource -name WindowsFeatureSet -ModuleName PSDesiredStateConfiguration
        WindowsFeatureSet "DefaultIIS" {
    	    Name = 'FileAndStorage-Services',"Storage-Services","Web-Server" 
    Ensure = 'present'
     
        } 
    }
    dd 
    

The topic ‘How do I use WindowsFeatureSet?’ is closed to new replies.