Inspired by this great post on improvements in Windows Server 2012 I decided to give MinShell a go.
Unlike that post, however, I was starting from Server Core and wanted to add on MinShell (not start with Server regular and remove the additional components to be left with just MinShell). Not a problem, PowerShell can be used to install the “Graphical Management Tools and Infrastructure” feature.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
PS C:\> Add-WindowsFeature Server-Gui-Mgmt-Infra Add-WindowsFeature : The request to add or remove features on the specified server failed. Installation of one or more roles, role services, or features failed. The source files could not be downloaded. Use the "source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f0906 At line:1 char:1 + Add-WindowsFeature Server-Gui-Mgmt-Infra + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:PSObject) [Install-WindowsFeature], Exception + FullyQualifiedErrorId : DISMAPI_Error__Cbs_Download_Failure,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand Success Restart Needed Exit Code Feature Result ------- -------------- --------- -------------- False No Failed {} |
Hmm, bummer. That was unexpected!
In retrospect this is not surprising. It happens because (obviously) the binaries for the Server Manager GUI bits are not present in the installed system and so one must point the Add-WindowsFeature
cmdlet to a source where it can get these from.
Had it been a non-GUI feature such as DNS or DHCP, the binaries would already be installed as part of Server 2012 Core – but not enabled – and so all the cmdlet needed to do would be to enable the feature. (However: if it were a non-GUI feature whose binaries were removed via the Uninstall-WindowsFeature
cmdlet with the –Remove
switch, then we would have had to point Add-WindowsFeature
to a source if we wanted to install these features later).
The Add-WindowsFeature
cmdlet has a –Source
switch which lets you specify a path from where it can pick up the binaries. This must point to the c:Windows
folder and that’s where the binaries are copied over from. If you have another Windows Server 2012 (non-Core) you can share its c:Windows
folder and point –Source
to that. Or you can mount the Windows Server 2012 (non-Core) install image from WIM file in the installation DVD and point –Source
to that. If you have the WIM file from the installation DVD on a network location, you can also point to the Windows Server 2012 (non-Core) install image in that by prefixing the path with WIM:
like this: –Switch wim:pathtowimfile.wim:2
(where 2 is the index of the image in this WIM file).
WIM files are sort of like containers for disk images. A single WIM file can contain many disk images – often with overlapping files – and so the size of the WIM file isn’t necessarily equal to the size of all the disk images combined. It is also a file based disk image format – meaning the images contain the actual file system and files within, not just binary data like a sector based format (such as ISO or VHD files). This is why you can actually “mount” an image from the Windows Server 2012 DVD on a folder and then browse this image as a regular file system – because it is a regular file system! The Windows installation DVDs usually contain the installation WIM file – called install.wim
– in the Sources
folder.
The DISM (Deployment Image Servicing and Management) command is your friend when it comes to WIM files. We met DISM earlier in the context of enabling/ disabling features and while it has a pretty straight-forward syntax it’s kind of ugly. Apart from enabling/ disabling features, you can also use DISM to inspect WIM files, mount the images within them, make changes to these images, and so on.
Before mounting an image in a WIM file, we need to inspect it to see what images are present. The /getwiminfo
switch is your friend for 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 |
C:\>dism /get-wiminfo /wimfile:z:\sources\install.wim Deployment Image Servicing and Management tool Version: 6.2.9200.16384 Details for image : z:\sources\install.wim Index : 1 Name : Windows Server 2012 SERVERSTANDARDCORE Description : Windows Server 2012 SERVERSTANDARDCORE Size : 7,195,580,708 bytes Index : 2 Name : Windows Server 2012 SERVERSTANDARD Description : Windows Server 2012 SERVERSTANDARD Size : 11,999,848,937 bytes Index : 3 Name : Windows Server 2012 SERVERDATACENTERCORE Description : Windows Server 2012 SERVERDATACENTERCORE Size : 7,176,243,455 bytes Index : 4 Name : Windows Server 2012 SERVERDATACENTER Description : Windows Server 2012 SERVERDATACENTER Size : 11,995,224,677 bytes The operation completed successfully. |
As you can see, there are four images in this WIM file. Two of these images are 7GB in size, two are nearly 12GB in size. So one would expect the WIM file containing these images to be around (7*2+12*2=)36GB in size, but in reality the WIM file is just 3.1GB. This is because all these images share the files within them and in addition to that the files are compressed. We want to install the “Graphical Management Tools and Infrastructure” feature which is present in the Windows Server 2012 Standard image (index : 2) and so that’s the image we are interested in.
To mount this image, create a folder and invoke DISM with the /mount-wim
switch:
1 2 3 4 5 6 7 8 9 10 |
C:\>mkdir C:\Offline C:>dism /mount-wim /wimfile:z:\sources\install.wim /index:2 /mountdir:c:\Offline /readonly Deployment Image Servicing and Management tool Version: 6.2.9200.16384 Mounting image [==========================100.0%==========================] The operation completed successfully. |
Mind you, DISM is very finicky when it comes to syntax. There is no space between the /wimfile:
switch and its arguments; similarly no space between /mountdir
and its arguments.
If we navigate to the c:\Offline
folder we can see a regular file system with a Windows
folder. Navigate through this and you’ll see its just like the Windows
folder in a live Windows system. This is the folder we are interested in.
So back to Add-WindowsFeature
we now pass the above mentioned folder via the -Source
switch:
1 2 3 4 5 6 |
PS C:\>Add-WindowsFeature Server-Gui-Mgmt-Infra -Source C:\Offline\Windows Success Restart Needed Exit Code Feature Result ------- -------------- --------- -------------- True Yes SuccessRest... {Graphical Management Tools and Infrastruc... WARNING: You must restart this server to finish the installation process. |
Success! Restart, and type servermanager
in the command prompt that you get to launch MinShell!
DISM mounted images are persistent across reboots. So once you are done with it be sure to unmount the image with the /unmount-wim
switch:
1 2 3 4 5 6 7 8 9 10 |
C:\>dism /unmount-wim /mountdir:c:\offline /discard Deployment Image Servicing and Management tool Version: 6.2.9200.16384 Image File : z:\sources\install.wim Image Index : 1 Unmounting image [==========================100.0%==========================] The operation completed successfully. |
The /discard
switch tells DISM we are not interested in it saving any of our changes to the image (not that we made any changes here; but in theory one could and save it back to the image).
Have fun with MinShell!