Once your Server Core network etc are configured it’s time to enable/ disable Windows features and roles.
To enable/ disable/ list Windows features and roles it’s probably easiest to import the ServerManager module into PowerShell and use the three cmdlets provided. But just in case you are not into PowerShell, or don’t want to install PowerShell and it’s dependency .NET (you are on Server Core and PowerShell & .NET aren’t installed by default there) there are two alternatives.
DISM
DISM is short for Deployment Image Servicing and Management. As the name suggests, it’s a tool for managing the disk image using which you deploy Windows. Starting with Windows Vista the installation files of Windows are stored in a (file based) disk image called the Windows Imaging Format (WIM). DISM is a tool that can manage this disk image before it’s deployed to a computer. But DISM is not just about managing disk images before they are deployed; it can be used also to manage a running instance of a deployed image. The latter is what we are interested here.
Disk images prior to deployment are known as offline images. Disk images that are currently running as the OS within which DISM is invoked are called online images. When you are dealing with an online image you also pass the switch /online
to DISM.
DISM was introduced with Windows 7/ Windows Server 2008 R2 and has a pretty straight-forward syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
C:\Users\Administrator>dism /online /? Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 The following commands may be used to service the image: ... PACKAGE SERVICING COMMANDS: /Add-Package - Adds packages to the image. /Remove-Package - Removes packages from the image. /Enable-Feature - Enables a specific feature in the image. /Disable-Feature - Disables a specific feature in the image. /Get-Packages - Displays information about all packages in the image. /Get-PackageInfo - Displays information about a specific package. /Get-Features - Displays information about all features in a package. /Get-FeatureInfo - Displays information about a specific feature. /Cleanup-Image - Performs cleanup and recovery operations on the image. ... |
The switches of interest to use are /Enable-Feature
, /Disable-Feature
, and /Get-Features
.
To get a list of available features:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
C:\Users\Administrator>dism /online /get-features /? Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 /Get-Features [/Format:] [/PackagePath:] [/PackageName:] Displays information about all features found in a specific package. If you do not specify a package name or path, all features in the image will be listed. /PackagePath can point to either a .cab file or a folder. Use the /Format option to specify a table or list format for the output. If /Format is not specified the option is formatted as a list. ... C:\Users\Administrator>dism /online /get-features /format:table Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Features listing for package : Microsoft-Windows-ServerCore-Package~31bf3856ad364e35~amd64~~6.1.7600.16385 ----------------------------------------------------------- | -------- Feature Name | State ----------------------------------------------------------- | -------- NetworkLoadBalancingHeadlessServer | Disabled SUACore | Disabled SUACore-WOW64 | Disabled WindowsServerBackup | Disabled WindowsServerBackupCommandlet | Disabled MultipathIo | Disabled DNS-Server-Core-Role | Disabled FRS-Infrastructure | Disabled BitLocker | Disabled ... C:\Users\Administrator>dism /online /enable-feature /featurename:ServerManager-PSH-Cmdlets Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. C:\Users\Administrator>dism /online /get-features /format:table | find "PowerShell" ActiveDirectory-PowerShell | Disabled MicrosoftWindowsPowerShell | Disabled MicrosoftWindowsPowerShell-WOW64 | Disabled |
To enable a feature:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
C:\Users\Administrator>dism /online /enable-feature /? Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 /Enable-Feature /FeatureName: [/PackageName:] Enables a specified feature. If the package name is not specified, the Windows Foundation package is assumed. Feature names are case-sensitive. ... C:\Users\Administrator>dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Enabling feature(s) [==========================100.0%==========================] Error: 50 The operation completed but MicrosoftWindowsPowerShell feature was not enabled. Ensure that the following parent feature(s) are enabled first. If they are already enabled, refer to the log file for further diagnostics. NetFx2-ServerCore C:\Users\Administrator>dism /online /enable-feature /featurename:NetFx2-ServerCore Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. C:\Users\Administrator>dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. C:\Users\Administrator>dism /online /enable-feature /featurename:ServerManager-PSH-Cmdlets Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. |
As you can see, feature names are case sensitive (eugh!!), and DISM doesn’t automatically enable dependent features – we have to enable them ourselves (good in a way coz DISM won’t enable a whole bunch of dependencies without me realizing, but I wish there were a way to say go ahead and enable whatever’s required). In contrast, if you try enabling a feature using PowerShell with the ServerManager module, dependencies are automatically taken care of.
(Update: DISM in Windows Server 2012 and Windows 8 has a /all
switch that automatically installs all the dependencies.)
The feature names are also not very intuitive – for instance to enable AD DS you need to enable the DirectoryServices-DomainController-ServerFoundation
feature but that’s not very obvious coz of the ServerFoundation
tacked at the end of the feature name, which makes you think it might be a scaled down version of AD DS. (Just as an aside: in the specific case of AD DS, even if you don’t enable the afore-mentioned feature yourself, dcpromo
automatically enables it as part of its tasks). This TechNet article is helpful in understanding what the feature names are.
I also hate the fact the fact that there are so many switches to type, but hey, at least the names are logical and I am glad DISM doesn’t have any dependencies and works out of the box on Server Core too. PowerShell has much better switches, but you need DISM sort of to enable PowerShell and the ServerManage module features.
Apart from enabling and disabling features, it’s worth knowing that DISM can be used to upgrade between editions. Say if you are running Server Core Standard and want to move to Server Core Enterprise, DISM can do that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
C:\Users\Administrator>dism /online /? Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 The following commands may be used to service the image: WINDOWS EDITION SERVICING COMMANDS: /Set-ProductKey - Populates the product key into the offline image. /Get-TargetEditions - Displays a list of Windows editions that an image can be upgraded to. /Get-CurrentEdition - Displays the editions of the specified image. /Set-Edition - Upgrades the Windows image to a higher edition. ... C:\Users\Administrator>dism /online /get-currentedition Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Current edition is: Current Edition : ServerStandardCore The operation completed successfully. C:\Users\Administrator>dism /online /get-targeteditions Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Editions that can be upgraded to: Target Edition : ServerDataCenterCore Target Edition : ServerEnterpriseCore The operation completed successfully. |
Read more about DISM and upgrading images at this TechNet article and blog post.
Lastly, DISM can also be used to query the installed drivers:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
C:\Users\Administrator>dism /online /get-drivers Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Obtaining list of 3rd party drivers from the driver store... Driver packages listing: Published Name : oem0.inf Original File Name : vboxguest.inf Inbox : No Class Name : System Provider Name : Oracle Corporation Date : 10/26/2012 Version : 4.2.4.0 Published Name : oem1.inf Original File Name : vboxvideo.inf Inbox : No Class Name : Display Provider Name : Oracle Corporation Date : 10/26/2012 Version : 4.2.4.0 Published Name : oem2.inf Original File Name : netkvm.inf Inbox : No Class Name : Net Provider Name : Red Hat Inc. Date : 2/13/2012 Version : 61.63.103.2200 The operation completed successfully. |
Unfortunately while there is a /Add-Driver
switch for adding drivers, it doesn’t work against an online image.
OCSetup
OCSetup is short for Optional Components Setup. This tool was introduced in Windows Vista/ Server 2008 specifically for Server Core. Windows Vista/ Server 2008 had the new modular architecture of roles and features, along with the Server Manager tool (GUI and command line) to manage these. However, Server Manager depends on .NET which is not enabled by default on Server Core, and so the OCSetup tool was provided for Server Core. This tool has a counterpart called OCList that gets a list of the optional components.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
C:\Users\Administrator>oclist |more Use the listed update names with Ocsetup.exe to install/uninstall a server role or optional feature. Adding or removing the Active Directory role with OCSetup.exe is not supported. It can leave your server in an unstable state. Always use DCPromo to install or uninstall Active Directory. =========================================================================== Microsoft-Windows-ServerCore-Package Not Installed:BitLocker Not Installed:BitLocker-RemoteAdminTool Not Installed:CertificateServices Not Installed:ClientForNFS-Base Not Installed:CoreFileServer Not Installed:DFSN-Server Not Installed:DFSR-Infrastructure-ServerEdition Not Installed:DHCPServerCore Not Installed:DNS-Server-Core-Role Not Installed:FRS-Infrastructure Not Installed:IIS-WebServerRole | |--- Not Installed:IIS-FTPServer | | | |--- Not Installed:IIS-FTPExtensibility | | ... |
The names returned by OCList are same as the ones given by DISM.
Once you’ve identified the features you’d like, enable them using OCSetup
:
1 2 3 4 5 6 7 8 9 |
C:\Users\Administrator>oclist |find "Cmdlets" | |--- Not Installed:BestPractices-PSH-Cmdlets | |--- Installed:ServerManager-PSH-Cmdlets C:\Users\Administrator>ocsetup BestPractices-PSH-Cmdlets C:\Users\Administrator>oclist |find "Cmdlets" | |--- Installed:BestPractices-PSH-Cmdlets | |--- Installed:ServerManager-PSH-Cmdlets |
Similar to DISM, OCSetup too is case sensitive and doesn’t automatically install dependent features. Moreover, it doesn’t give any output. To see whether the feature was enabled, you run OCList again and verify that it’s installed.
OCSetup has a much simpler syntax than DISM, but also doesn’t have the additional features that DISM has. Moreover, DISM is a useful tool to know for creating offline images for deploying on other machines, so it’s worth familiarizing oneself with DISM.