How to check if you’re running on a Windows Core Edition

While writing my SQL Server template installer, I ran into a big problem – I had to determine if my server was a Core Edition or not, based on the Windows edition. The biggest challenge was that it had to be as OS-independent as possible. Our customers run several OSs, so I needed something that could run on Windows 2008 R2, Windows 2012 R2 and be future-proof for Windows 2016.

Surfing the interwebs, I found several ways of doing this, but none of them seemed able to work on all the operating systems I wanted to write the template for.

First I tried to use $sku = $((gwmi win32_operatingsystem).OperatingSystemSKU) as described by Jeffrey Snover. But while this approach worked perfectly well for Windows 2008 R2, it didn’t work for Windows 2016.

The default install of Windows 2016 is a core edition, so $sku will return 8 (Datacenter Server Edition) instead of the expected 12 (Datacenter Server Core Edition), even when running the core edition. So that didn’t work out … In fact, the simplest thing to do is to check if the GUI shell is actually installed. But hey, wait a minute. Isn’t that easy if you use Get-WindowsFeature?

You can check all the installed features, can’t you? So by changing the code to: $IsGuiInstalled = $(Get-WindowsFeature -Name “Server-gui-shell” | Select InstallState) I could now verify if $IsGuiInstalled –eq “Available”. If the GUI is still available, you’re running a core edition of Windows. If the state is Installed, you have the GUI ;-)

So my code became:

$IsGuiInstalled = Get-WindowsFeature -Name “Server-gui-shell” | Select InstallState
#Check if we are running on a windows core edition, in that case $IsGuiInstalled should return “Available”
if($IsGuiInstalled -eq “Available”)
{ Write-Verbose “Running on windows GUI” }
{ Write-Verbose “Running on windows Core”}

Database specific security in SQL Server
There are many different ways to secure your database. In this blog post we will give most of them a...
SQL Server security on server level
In this blog, we’re going to look at the options we have for server level security. In SQL Server we...
Microsoft SQL Server history
Since its inception in 1989, Microsoft SQL Server is a critical component of many organizations' data infrastructure. As data has...
Power BI Desktop is een prachtige tool om snel data-analyses te kunnen uitvoeren. Je connecteert op een databron, importeert en...
dba image
DBA is not that scary
Often when talking to people who are looking for a career path in the data world I feel like there...
How do you link an SCD Type 2 table in Power Query?
This article uses a simple example to demonstrate how to link an SCD Type 2 table in Power Query to...