Reduce Server image size

A useful feature of Server 2012 R2, to reduce the size of an image (such as a template), is to compress the manifest files and inactive payloads, i.e. uninstallation data for updates. Reducing the size of an image can be useful, especially on Server Core, where Disk Cleanup isn’t readily available, as this reduces the time needed to deploy a VM. Having tested this recently, the image size was reduced by 10 %. Be warned that this command can take several hours to run.

dism /Online /Cleanup-Image /StartComponentCleanup

If you would like to go further, the binaries for disabled features can be removed completely, but this removes both the features and any associated updates, which means that installing the features again will necessitate access to the installation media and the relevant updates.

Get-WindowsFeature | ? { $_.InstallState -eq Available } | Uninstall-WindowsFeature -Remove

Source: TechNet.

“The source files could not be found” when installing a Server feature

The source files could not be found. Error 0x800f0906.

This infamous error, that may be returned when installing a Windows Server feature, indicates the inability of the installer to access the source files or the correct version of the source files. As per this blog, even specifying the installation media may not resolve the problem, as the installer may be expecting a different version of the binaries. Allowing updates from WSUS may work, but in my experience this isn’t usually the case.

There are several options for resolving this problem, e.g.:

Install-WindowsFeature AD-Domain-Services -Source Online
Install-WindowsFeature AD-Domain-Services -Source wim:"X:\sources\install.wim":2
Install-WindowsFeature AD-Domain-Services -Source "X:\sources\sxs\"

Obviously, adjust the drive letter to the appropriate letter of your mounted installation ISO.

One particularly troublesome feature is AD Domain Services, for which I have found that the only solution is to provide access to a copy of the SxS store of the same binary version, e.g. the SxS store on another similarly-patched server. Using Install-WindowsFeature accesses network shares using the server’s context, which generally won’t have access to an admin share on a DC, so the Enable-WindowsOptionalFeature cmdlet must be used, which uses the current user’s context:

Enable-WindowsOptionalFeature -Online -FeatureName DirectoryServices-DomainController -All -Source "\\DC01\C$\Windows\WinSxS\"

Remote administration of Server 2012 R2 Core

Windows Server 2012 R2 Core requires some configuration changes to the firewall and registry to enable remote administration. I’ve struggled to find a comprehensive list, so I’ll keep one here of the commands I use regularly.


Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Enable-NetFirewallRule -DisplayGroup "Windows Management Instrumentation (WMI)"
Enable-NetFirewallRule -DisplayGroup "Remote Event Log Management"
Enable-NetFirewallRule -DisplayGroup "Remote Service Management"
Enable-NetFirewallRule -DisplayGroup "File and Printer Sharing"
Enable-NetFirewallRule -DisplayGroup "Remote Scheduled Tasks Management"
Enable-NetFirewallRule -DisplayGroup "Performance Logs and Alerts"
Enable-NetFirewallRule -DisplayGroup "Windows Remote Management"
Enable-NetFirewallRule -DisplayGroup "Windows Firewall Remote Management"
Enable-NetFirewallRule -DisplayGroup "Routing and Remote Access"


Install-WindowsFeature Web-Mgmt-Service
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WebManagement\Server" -Name "EnableRemoteManagement" -Value "1"
New-NetFirewallRule -Action Allow -Direction Inbound -DisplayName "IIS Management" -Service "WMSVC"
Set-Service "WMSVC" -StartupType Automatic
Start-Service "WMSVC"