Waclaw Chrabaszcz
... there is no spoon ...

How to install Windows Server 2008/2012 roles/features using PowerShell

Wednesday, December 12, 2012 12:00 PM

Let's make it faster …

A simple PowerShell script

Import-Module Servermanager

Add-WindowsFeature Application-Server,Hyper-V,WAS -norestart

And of course shutdown –r at the end


List of roles and features: 

Role/Service or Main Feature R/S/F Name Installatiom command
DHCP Server DHCP Server DHCP
Print Services Print Server Print-Services
  Internet Printing Print-Internet
  LPD Service Print-LPD-Service
Terminal Services Terminal Services Terminal-Services
  Terminal Server TS-Terminal-Server
  TS Licensing TS-Licensing
  TS Gateway TS-Gateway
  TS Web Access TS-Web-Access
  TS Session Broker TS-Session-Broker
Active Directory Domain Services AD N/A
  Active Directory Domain Controller ADDS-Domain-Controller
  Identity Management for UNIX ADDS-Identity-Management
  Server for Network Information Service ADDS-NIS
  Password Synchronization ADDS-Password-Sync
DNS Server DNS  
File Services File Services N/A
  Distributed File System (DFS) FS-DFS
  DFS Namespace FS-DFS-Namespace
  DFS Replication FS-DFS-Replication
  File Server Resource Manager FS-Resource-Manager
  Services for Network File System FS-NFS-Services
  Windows Search Service FS-Search-Service
  Windows Server 2003 File Services FS-Win2003-Services
  File Replication Service FS-Replication
  Indexing Service FS-Indexing-Service
Web Server Web Server (IIS) Web-Server
  Internet Information Services Web-WebServer
  Common HTTP Features Web-Common-Http
  Static Content Web-Static-Content
  Default Document Web-Default-Doc
  Directory Browsing Web-Dir-Browsing
  HTTP Errors Web-Http-Errors
  HTTP Redirection Web-Http-Redirect
  Application Development Web-App-Development
  ASP.NET Web-Asp-Net
  .NET Extensibility Web-Net-Ext
  ISAPI Extensions Web-ISAPI-Ext
  ISAPI Filters Web-ISAPI-Filter
  Server Side Includes Web-Includes
  Health and Diagnostics Web-Health
  HTTP Logging Web-Http-Logging
  Logging Tools Web-Log-Libraries
  Request Monitor Web-Request-Monitor
  Tracing Web-Http-Tracing
  Custom Logging Web-Custom-Logging
  ODBC Logging Web-ODBC-Logging
  Security Web-Security
  Basic Authentication Web-Basic-Auth
  Windows Authentication Web-Windows-Auth
  Digest Authentication Web-Digest-Auth
  Client Certificate Mapping Authentication Web-Client-Auth
  IIS Client Certificate Mapping Authentication Web-Cert-Auth
  URL Authorization Web-Url-Auth
  Request Filtering Web-Filtering
  IP and Domain Restrictions Web-IP-Security
  Performance Web-Performance
  Static Content Compression Web-Stat-Compression
  Dynamic Content Compression Web-Dyn-Compression
  Management Tools Web-Mgmt-Tools
  IIS Management Console Web-Mgmt-Console
  IIS Management Scripts and Tools Web-Scripting-Tools
  Management Service Web-Mgmt-Service
  IIS 6 Management Compatibility Web-Mgmt-Compat
  IIS 6 Metabase Compatibility Web-Metabase
  IIS 6 WMI Compatibility Web-WMI
  IIS 6 Scripting Tools Web-Lgcy-Scripting
  IIS 6 Management Console Web-Lgcy-Mgmt-Console
  FTP Publishing Service Web-Ftp-Publishing
  FTP Server Web-Ftp-Server
  FTP Management Console Web-Ftp-Mgmt-Console
Active Directory Federation Services ADFS None
  Federation Service ADFS-Federation
  Federation Service Proxy ADFS-Proxy
  Web Agents ADFS-Web-Agents
  Claims-aware Agent ADFS-Claims
  Windows Token-based Agent ADFS-Windows-Token
Active Directory Lightweight Directory Services Formerly ADAM ADLDS
Application Server Application Server Application-Server
  Application Server Core AS-AppServer-Core
  Web Server Support AS-Web-Support
  COM+ Network Access AS-Ent-Services
  TCP Port Sharing AS-TCP-Port-Sharing
  Windows Process Activation Service Support AS-WAS-Support
  HTTP Activation AS-HTTP-Activation
  Message Queuing Activation AS-MSMQ-Activation
  TCP Activation AS-TCP-Activation
  Named Pipes Activation AS-Named-Pipes
  Distributed Transaction Support AS-Dist-Transaction
  Incoming Remote Transactions AS-Incoming-Trans
  Outgoing Remote Transactions AS-Outgoing-Trans
  WS-Atomic Transaction Support AS-WS-Atomic
Active Directory Certificate Services Active Directory Certificate Services N/A
  Certification Authority ADCS-Cert-Authority or AD-Certificate
  Online Certificate Status Protocol ADCS-Online-Cert
Fax Server Fax Server Fax
Network Policy and Access Services Network Policy and Access Services NPAS
  Network Policy Server NPAS-Policy-Server
  NPAS Routing and Remote Access Services NPAS-RRAS-Services
  Remote Access Service NPAS-RRAS
  Routing NPAS-Routing
  Health Registration Authority NPAS-Health
Windows Deployment Services Windows Deployment Services WDS
Hyper-V Hyper-V Hyper-V
Failover Clustering Failover Clustering Failover-Clustering
Network Load Balancing Network Load Balancing NLB
Desktop Experience Desktop Experience Desktop-Experience
.NET Framework 3.0 Features .NET Framework 3.0 Features NET-Framework
.NET Framework 3.0 .NET Framework 3.0 NET-Framework-Core
XPS Viewer XPS Viewer NET-XPS-Viewer
Windows Communication Foundation Activation Components Windows Communication Foundation Activation Components NET-Win-CFAC
HTTP Activation HTTP Activation NET-HTTP-Activation
Non-HTTP Activation Non-HTTP Activation NET-Non-HTTP-Activ
Windows System Resource Manager Windows System Resource Manager WSRM
Wireless Networking Wireless Networking Wireless-Networking
Windows Server Backup Windows Server Backup Backup
WINS Server WINS Server WINS-Server
Remote Assistance Remote Assistance Remote-Assistance
Simple TCP/IP Services Simple TCP/IP Services Simple-TCPIP
Telnet Client Telnet Client Telnet-Client
Telnet Server Telnet Server Telnet-Server
Subsystem for UNIX-based Applications Subsystem for UNIX-based Applications Subsystem-UNIX-Apps
RPC over HTTP Proxy RPC over HTTP Proxy RPC-over-HTTP-Proxy
SMTP Server SMTP Server SMTP-Server
LPR Port Monitor LPR Port Monitor LPR-Port-Monitor
Storage Manager for SANs Storage Manager for SANs Storage-Mgr-SANS
BITS Server Extensions BITS Server Extensions BITS
Message Queuing Message Queuing MSMQ
  Message Queuing Services MSMQ-Services
  Message Queuing Server MSMQ-Server
  Directory Service Integration MSMQ-Directory
  Message Queuing Triggers MSMQ-Triggers
  HTTP Support MSMQ-HTTP-Support
  Multicasting Support MSMQ-Multicasting
  Routing Service MSMQ-Routing
  Windows 2000 Client Support MSMQ-Win2000
  Messaging Queue DCOM Proxy MSMQ-DCOM
Windows Process Activation Service Windows Process Activation Service WAS
  Process Model WAS-Process-Model
  .NET Environment WAS-NET-Environment
  Configuration APIs WAS-Config-APIs
Windows Internal Database Windows Internal Database Windows-Internal-DB
BitLocker Drive Encryption BitLocker Drive Encryption BitLocker
Multipath I/O Multipath I/O Multipath-IO
Internet Storage Naming Server Internet Storage Naming Server ISNS
Removable Storage Manager Removable Storage Manager Removable-Storage
TFTP Client TFTP Client TFTP-Client
SNMP Services SNMP Services SNMP-Services
  SNMP Service SNMP-Service
  SNMP WMI Provider SNMP-WMI-Provider
Services for Network File System Services for Network File System NFS-Services
Internet Printing Client Internet Printing Client Internet-Print-Client
Peer Name Resolution Protocol Peer Name Resolution Protocol PNRP
Connection Manager Administration Kit Connection Manager Administration Kit CMAK
Remote Server Administration Tools Remote Server Administration Tools RSAT
  Role administration tools RSAT-Role-Tools
  Active Directory Certificate Services Tools RSAT-ADCS
  Active Directory Domain Services Tools RSAT-ADDS
  Active Directory Domain Controller Tools RSAT-ADDC
  Server for NIS Tools RSAT-SNIS
  Active Directory Lightweight Directory Services Tools RSAT-ADLDS
  Active Directory Rights Management Services (AD RMS) Tools RSAT-RMS
  DHCP Server Tools RSAT-DHCP
  DNS Server Tools RSAT-DNS
  Fax Server Tools RSAT-Fax
  DFS Management Console Tools RSAT-DFS-Mgnt-Con
  File Server Resource Manager Management Console Tools RSAT-FSRM-Mgnt
  Hyper-V Tools RSAT-Hyper-V
  Services for Network File System Tools RSAT-NFS-Admin
  File Services Tools RSAT-File-Services
  Network Policy and Access Services Tools RSAT-NPAS
  Health Registration Authority Tools RSAT-HRA
  Network Policy Server Tools RSAT-NPS
  Print Services Tools RSAT-Print-Services
  Web Server (IIS) Tools RSAT-Web-Server
  Terminal Services Tools RSAT-TS
  TS RemoteApp Tools RSAT-TS-RemoteApp
  TS Gateway Tools RSAT-TS-Gateway
  TS Licensing Tools RSAT-TS-Licensing
  UDDI Services Tools RSAT-UDDI
  Feature administration tools RSAT-Feature-Tools
  BitLocker Drive Encryption Tools RSAT-BitLocker
  BITS Server Extensions Tools RSAT-BITS-Server
  Failover Clustering Tools RSAT-Clustering
  Network Load Balancing Tools RSAT-NLB
  SMTP Server Tools RSAT-SMTP
  Windows Deployment Services Tools RSAT-WDS
  WINS Server Tools RSAT-WINS
  Hyper-V Tools RSAT-Hyper-V
Windows PowerShell Windows PowerShell PowerShell
Group Policy Management Group Policy Management GPMC
Quality Windows Audio Video Experience Quality Windows Audio Video Experience Qwave 


# re: How to install Windows Server 2008/2012 roles/features using PowerShell

Doesnt look like this option is available on windows 2012 : Removable Storage Manager Removable Storage Manager Removable-Storage 8/20/2013 12:07 PM | Justin

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

Thanks Justin, I am very busy last days, however I'm going to post Server 2012 R2 update soon. I will let you know. 9/2/2013 8:08 AM | Waclaw

# How to install specific roles and features

I tried all the below ways to get this sorted out

My use case is to install application server roles and additional features like as below







powershell import-module servermanager ;

add-windowsfeature AS-Outgoing-Trans,AS-NET-Framework

add-windowsfeature AS-Incoming-Trans,NET-Framework

Out put of the above commands give the result as below

1. Installs .net framework 3.x along with AS-Inming/outgoing trans and additional to that Windows process activation service support is also getting installed


Tried other way around and this installs even AS-WAS-Support along with everything.

import-module servermanager ;

Add-WindowsFeature Application-Server,AS-NET-Framework

Add-WindowsFeature 'AS-incoming-Trans',AS-Dist-Transaction,AS-NET-Framework,Application-Server

Add-WindowsFeature Application-Server,AS-Dist-Transaction,AS-Outgoing-Trans

Add-WindowsFeature AS-Incoming-Trans,AS-NET-Framework

remove-WindowsFeature Application-Server,AS-WAS-Support

remove-WindowsFeature Application-Server,AS-HTTP-Activation

I need to get this sorted out as it is needed for SQL Server.

Thnx in advance
10/11/2013 2:32 PM | Sonu

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

If you want to install Windows Server Backup up 2012R2 its Add-WindowsFeature Windows-Server-Backup
Just using plain 'backup' won't Work. 11/14/2013 9:24 AM | Morten Nielsen

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

hi, how do i removed bitlocker from windows2008 r2 using powershell for multiple servers? 1/31/2014 5:15 AM | ali

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

please take a look on http://geekswithblogs.net/Wchrabaszcz/archive/2012/12/10/how-to-install-.net-3.5-on-windows-server-2012.aspx
Bitlocker command-lets are avaliable only in Server 2012 R2, I'll try to post about it soon, for disabling/enabling of BitLocker on 2008R2 I would recommend you local execution of command line scripts: SCCM package, or startup script, or Task scheduler action. Let'm me play with my servers and i will post something soon.
3/15/2014 12:15 PM | wchrabaszcz

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

I am unable to import module servermanager in windows server 2008. please help me how to import servermanager module in 2008 server. 3/25/2014 6:04 PM | Samit Manna

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

I am unable to import module servermanager in windows server 2008. 3/25/2014 6:05 PM | Samit Manna

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

Hello Samit, try to use ServerManagerCMD.exe instead e.g ServerManagerCMD -Install NET-Framework-Core. For pure 2008 I would recommend you to install the most rescent service pack, and after that it should works. 4/19/2014 4:17 PM | wchrabaszcz

# how to install .Net Feature using Powershell in Windows 2008 R2 ?

Anyone knows? 8/15/2015 7:14 PM | j

# re: How to install Windows Server 2008/2012 roles/features using PowerShell

hello, first: Import-Module ServerManager , second Add-WindowsFeature NET-Framework-Core. it should works for you. As far as I remember 4.5 is not the part of 2008 build and you'll need to download and install a standalone MSI 8/26/2015 2:38 PM | wchrabaszcz

Post a comment