Just a script I made to manage a Server's Core GUI. Hope you all like it!
Function Enable-ServerCoreGui {
# Import the module
Import-Module -Name DISM -ErrorAction Stop
# is it already enabled??
if ((Get-WindowsOptionalfeature -online -Feature ServerCore-FullServer).state -eq 'Enabled'){
"Servercore-FullServer is already enabled"
}
if ((Get-WindowsOptionalfeature -online -Feature Server-GUI-Shell).state -eq 'Enabled'){
"Server-GUI Shell is already enabled"
}
if ((Get-WindowsOptionalfeature -online -Feature Server-Gui-Mgmt).state -eq 'Enabled'){
"Server-Gui-Mgmt is already enabled"
}
# Enable the features needed to add the GUI
Enable-WindowsOptionalFeature –Online -NoRestart `
-Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt
# So Restart the computer
Restart-computer
}
Function Disable-ServerCoreGui {
# Import the module
Import-Module -Name DISM -ErrorAction Stop
# Disable all the features needed to add the GUI
# if any are already disabled, oh well - they're still disabled.
Disable-WindowsOptionalFeature –Online -NoRestart `
-Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt
# Finally Restart the computer
Restart-computer
}