Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have scripted against sysocmgr in Windows XP, servermanagercmd in server 2008, and now I find that I have to use a new PowerShell module servermanager to install features on Server 2008 R2 and so I would expect that I would use the same module in Windows 7 but it's not there.

How can I install Windows features using the command line or PowerShell in Windows 7?

share|improve this question
Time has finally provided a way using powershell, my answer is below. – BigHomie Dec 19 '13 at 15:04
up vote 13 down vote accepted
dism.exe /online /?

also, check out

share|improve this answer
specifically this MSDN page tells you to use a command like this: dism /online /Enable-Feature /FeatureName:{feature} use /Get-Features to list all available features. – Eric Falsken May 7 '13 at 1:51
@EricFalsken This is now possible via powershell using the dism module. – BigHomie Dec 19 '13 at 15:03

For a true powershell experience, you need to download the Windows AIK for 8.0 and use the dism module. It's found in

C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\<arch>\DISM

and you can just point powershell to that folder with

Import-Module C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\<arch>\DISM

Make sure you replace < arch > with the architecture of the machine powershell is running on. That DISM folder can even be copied and redistributed to machines if need be (speaking on functionality, I don't know if redistributing is actually allowed by Microsoft).

The specific command to toss out a Windows optional feature is

Get-WindowsOptionalFeature -Online | where FeatureName -eq mediacenter

That will return a Microsoft.DISM.Commands.BasicFeatureObject, as seen here. From there, you can set the state property to disabled, like

$(Get-WindowsOptionalFeature -Online | where FeatureName -eq mediacenter).state = 

and bye bye media center. Of course, this has to be run from an elevated prompt, and the -Online switch refers to the current running Windows, as opposed to an offline image.

Also, this module requires WMF 3.0 and that requires .NET 4.0, just FYI.

share|improve this answer
I was able to run Enable-WindowsOptionalFeature -FeatureName NetFx3 -Online on a Windows 8.1 machine without installing the AIK. I did, however, have the WMF5 preview installed; perhaps that provides it? The module is loaded from C:\windows\system32\windowspowershell\v1.0\Modules\Dism\Dism.psm1 – bshacklett Mar 23 '15 at 15:33

Attempting to run the PowerShell from Windows 7/8 will only get you this:

Get-WindowsFeature : The target of the specified cmdlet cannot be a Windows client-based operating system.

dism is the only way I've found that works.

share|improve this answer

Add ServerManager-feature manually. Then you can add servermanager-module:

import-module servermanager


share|improve this answer
how would you add ServerManager feature separately? – fschwiet May 9 '11 at 1:17
This would work for Windows 2008R2 and newer, but not for Windows 7. – Trondh May 16 '13 at 19:01
ocsetup.exe /?

In addition to dism it appears you can also use ocsetup which is installed by default on Windows Vista and Windows Server 2008. If you were looking to script something that works across all three of these then this would probably be the way to go.

share|improve this answer

For the Powershell part, open the 'Windows Powershell Modules' prompt and enter

PS1> Add-WindowsFeature [feature name]


Add-WindowsFeature SMTP-Server

Get-WindowsFeature shows you the names of all the available features

share|improve this answer
I'm pretty sure this only works on Windows Server 2008 R2. – Jeffery Hicks Nov 9 '09 at 20:34
Jeffery is correct, this does not work in windows 7 by default. If you know of a way to get it working I would like to know. – Chris Magnuson Nov 9 '09 at 21:15

You could use a remote session from Windows 7 to a Windows Server 2008 R2 box and run Add-WindowsFeature. I have not been able to find it on Win7 even with RSAT installed.

share|improve this answer
Wouldn't that add the feature to the Windows Server 2008 R2 box and not to the local Windows 7 instance? If not please explain. – Chris Magnuson Nov 9 '09 at 21:16

protected by Tom O'Connor Sep 12 '13 at 9:49

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.