4

I'm wanting to script the "Turn Windows Features On or Off" functionality for my development group so that we'll have a means of ensuring that everyone is running on the same configurations. I know that you can do this in Win Server 2008, but in Windows 7 it appears that the "Add-WindowsFeature" cmdlet isn't available. I've also read that it is possible using DISM.exe, but I'm afraid to use this without any prior experience because it seems risky.

It doesn't necessarily have to be scripting. Windows Features is just one of serveral configurations that developers are responsible for modifying personally. It would also be nice to ensure (for example) that IIS and certain services are configured properly on a given developer's machine. If there's a larger scale tool that could give us this functionality, I would be interested in that too. I'm just hesitant of DISM because I don't know it and it seems to change the image files.

2 Answers 2

8

List available features:

dism /Online /Get-Features

Enable feature:

dism /Online /Enable-Feature /FeatureName:featureA

Disable feature:

dism /Online /Disable-Feature /FeatureName:featureB

Using dism is no more/less risky that accessing appwiz.cpl as an administrator.

re-edit

Here's a script I've actually tried before posting. It will iterate available features and list their Feature Name as well as Display Name -- This is what appears in appwiz.cpl. I am still sure someone will post an elegant one-liner that puts this to shame:

@ECHO OFF
FOR /F "usebackq tokens=3,*" %%a in (`dism /Online /Get-Features ^| find /i "name"`) do (
    dism /Online /Get-FeatureInfo /FeatureName:"%%b" | find /i "name"
)
6
  • Thanks jscott, but Get-Features doesn't seem to give me the same set of features as actually opening "Windows Features". Specifically, I do not see "Microsoft .NET Framework 3.5.1" in the Get-Features results.
    – L.Moser
    Jan 14, 2011 at 20:35
  • @L.Moser: Not all features are named idential to the listing in appwiz.cpl. You're looking for NetFx3, case-sensitive... To turn it on dism /Online /Enable-Feature /FeatureName:NetFx3
    – jscott
    Jan 14, 2011 at 20:44
  • Actually, The two child nodes for "Microsoft .NET Framework 3.5.1" are "WCF HTTP Activation" and "WCF Non-HTTP Activation". These entries are available in Get-Features. Maybe I just missed something. Thanks again jscott, I think I have a better idea of how this works now.
    – L.Moser
    Jan 14, 2011 at 20:45
  • Is there a way to figure out the mapping from "Get-Features" to "Windows Features"?
    – L.Moser
    Jan 14, 2011 at 20:45
  • @L.Moser, My method for figuring out some of the more obscure mappings is to just add the feature on a test system and then see what is enabled. It helps if you send the output of Dism /online /Get-Features before and after you enable the feature to text files. Then you can use a diff utility.
    – Zoredache
    Jan 14, 2011 at 21:09
1

DISM is what you're looking for. You use the /online option to target the running OS rather than an offline image. This is how you add and remove windows roles and features in Server Core.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .