Is my 2012 server Core,Full or Minimal shell

In August Ned answered the following question on the Friday mail sack

I am trying out Windows Server 2012 and its new Minimal Server Interface. Is there a way to use WMI to determine if a server is running with a Full Installation, Core Installation, or a Minimal Shell installation?

# Requires -Version 3.0            
            
Function Get-ServerType {            
[Cmdletbinding()]            
param()            
Begin {            
    $HT = @{            
        ErrorAction = "Stop";            
        Class = "win32_serverfeature";            
    }            
}            
Process {            
    try{            
        $version = (Get-WmiObject -Class Win32_Operatingsystem -ErrorAction Stop)            
    } Catch {            
        Write-Warning -Message "Failed to get OS version"            
    }            
    if ([version]$version.Version -gt ([version]'6.2'))            
    {                    
        # Get the list of features            
        try            
        {            
            $ServerFeatures = Get-WmiObject  @HT            
        } catch {            
            Write-Warning -Message "Not running on a server"            
        }            
            
        if ($ServerFeatures)            
        {            
            $ServerFeatures | ForEach-Object -Process {            
                switch ($_.ID)            
                {            
                    99  {             
                        # Server Graphical Shell -> full install            
                        $hasShell = $true            
                        }            
            
                    478 {             
                        # Graphical management tools and infrastructure            
                        $hasInfra = $true            
                    }            
                    default {}            
                }            
            }            
            if ($hasShell -and $hasInfra)            
            {            
                $desc = 'Full'            
            } elseif ($hasInfra -and -not$hasShell) {            
                $desc = 'MinShell'            
            } else {            
                $desc = 'Core'            
            }            
                     
        } else {            
            $desc = 'Workstation'            
        }            
        [PSCustomObject]@{Type = $desc}            
    } else {            
        Write-Warning -Message "Not running on 6.2 plateform"            
    }            
}            
End {}            
} # end of function            
            
            
Advertisements

One thought on “Is my 2012 server Core,Full or Minimal shell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s