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?

link|improve this question

70% accept rate
feedback

5 Answers

up vote 3 down vote accepted
dism.exe /online /?

also, check out http://www.windowsnetworking.com/articles%5Ftutorials/Deploying-Windows-7-Part2.html

link|improve this answer
feedback

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

import-module servermanager

get-windowsfeature

link|improve this answer
1  
how would you add ServerManager feature separately? – fschwiet May 9 '11 at 1:17
feedback
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.

link|improve this answer
feedback

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

PS1> Add-WindowsFeature [feature name]

eg

Add-WindowsFeature SMTP-Server

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

link|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. – ObligatoryMoniker Nov 9 '09 at 21:15
feedback

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.

link|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. – ObligatoryMoniker Nov 9 '09 at 21:16
feedback

Your Answer

 
or
required, but never shown

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