kohera-logo-regular.svg

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” }
else
{ Write-Verbose “Running on windows Core”}

blog-security_1
Microsoft SQL Server history
Since its inception in 1989, Microsoft SQL Server is a critical component of many organizations' data infrastructure. As data has...
DSC_1388
Aggregaties
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...
blog-2303
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...
featured-2302
How to easily parse JSON in Power BI Desktop
Sometimes you want to use JSON data in Power BI. And sometimes Power BI doesn’t exactly do what you want...
header-2301
Power BI reports as monitoring tool
Who has not created monitoring reports or beautiful dashboards in Power BI? Would it not be great to show off...