When working with Windows Server 2012 deployments, administrators often need to distinguish between Core and Full installations programmatically. While WMI's Win32_OperatingSystem
class seems like the obvious solution, the OperatingSystemSKU
property behavior can be confusing.
The MSDN documentation suggests that Server Core installations should return 0x0000000D
(PRODUCT_STANDARD_SERVER_CORE), but in practice, Windows Server 2012 Core often reports 7
(PRODUCT_STANDARD_SERVER). This discrepancy requires alternative detection methods.
// Sample WMI query showing the issue
using (var searcher = new ManagementObjectSearcher("SELECT OperatingSystemSKU, Version, ProductType FROM Win32_OperatingSystem"))
{
foreach (ManagementObject obj in searcher.Get())
{
Console.WriteLine($"SKU: {obj["OperatingSystemSKU"]}, Version: {obj["Version"]}");
}
}
Here are three reliable approaches to identify Server Core installations:
1. Checking the InstallationType Property
The most accurate method is to use the InstallationType
property in newer PowerShell versions:
Get-CimInstance Win32_OperatingSystem | Select-Object InstallationType
# Returns "Server Core" for core installations
2. Windows Feature Analysis
Examine installed features using PowerShell:
$guiFeatures = @("Server-Gui-Mgmt-Infra","Server-Gui-Shell")
$installed = Get-WindowsFeature | Where-Object {$_.Installed -eq $true}
if (($installed.Name | Where-Object {$guiFeatures -contains $_}).Count -eq 0) {
Write-Host "This is a Server Core installation"
}
3. Registry-Based Detection
Check the registry for installation type:
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
$installType = (Get-ItemProperty -Path $regPath).InstallationType
if ($installType -eq "Server Core") {
# Core installation detected
}
For your specific requirement of creating targeted GPOs, you can use WMI filtering with this query:
SELECT * FROM Win32_OperatingSystem WHERE
(Version LIKE "6.2%" AND ProductType = 2 AND InstallationType = "Server Core")
This will accurately target only Windows Server 2012 Core installations, regardless of the OperatingSystemSKU
value.
Microsoft changed the SKU numbering scheme between server versions. While the documentation lists specific values, the actual implementation in Windows Server 2012 uses different numbering for Core installations. This explains why you're seeing value 7 instead of the expected 13 (0xD).
When working with Windows Server 2012 deployments, administrators often need to distinguish between Core and full GUI installations for configuration management. The common approach using WMI's Win32_OperatingSystem.OperatingSystemSKU
property appears to return ambiguous results.
According to Microsoft documentation (MSDN), Server Core installations should return specific SKU values:
PRODUCT_STANDARD_SERVER = 7
PRODUCT_STANDARD_SERVER_CORE = 0x0000000D (13 in decimal)
However, as reported in the question, Windows Server 2012 Core installations often return value 7 instead of the expected 13.
Since the SKU method appears unreliable for Server 2012 Core detection, here are alternative approaches:
# PowerShell method using Get-WindowsFeature
$guiStatus = (Get-WindowsFeature -Name Server-Gui-Mgmt-Infra).InstallState
if ($guiStatus -eq "Installed") {
Write-Host "Full GUI installation"
} else {
Write-Host "Core installation"
}
For more reliable detection across Windows Server versions:
# PowerShell using CIM
$installType = (Get-CimInstance -Namespace root\cimv2 -ClassName Win32_ServerManager).CurrentInstallationType
switch ($installType) {
"Server Core" { Write-Host "Core installation detected" }
"Server" { Write-Host "Full installation detected" }
default { Write-Host "Unknown installation type" }
}
For environments where PowerShell isn't available, this WMI query might help:
SELECT Caption,OtherTypeDescription FROM Win32_OperatingSystem
The OtherTypeDescription
field often contains "Server Core" for core installations.
For your specific Group Policy requirement, consider this WMI filter:
SELECT * FROM Win32_OperatingSystem WHERE
(Version LIKE "6.2%" AND ProductType = 2 AND OtherTypeDescription LIKE "%Core%")
This targets specifically Windows Server 2012 (version 6.2) core installations while excluding full GUI versions.
For most reliable detection across different Windows Server versions:
- Use
Win32_ServerManager.CurrentInstallationType
for Server 2012 R2 and later - Combine
OtherTypeDescription
with version checking for Server 2012 - Implement fallback checks when primary methods fail
# Comprehensive detection function
function Test-ServerCoreInstallation {
$os = Get-CimInstance Win32_OperatingSystem
if ($os.Version -like "6.2*") {
return ($os.OtherTypeDescription -like "*Core*")
} else {
$sm = Get-CimInstance -Namespace root\cimv2 -ClassName Win32_ServerManager -ErrorAction SilentlyContinue
return ($sm.CurrentInstallationType -eq "Server Core")
}
}