Skip to content

Instantly share code, notes, and snippets.

@stknohg
Last active September 28, 2016 01:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stknohg/1629d0832dd18ce12225 to your computer and use it in GitHub Desktop.
Save stknohg/1629d0832dd18ce12225 to your computer and use it in GitHub Desktop.
Windows Server 2016 TPにGUI Shellをインストールするやーつ(※GA版では使えないので注意)
#
# Windows Server 2016 TPにGUI Shellをインストールするやーつ
# ※ソースドライブは最初に見つかったドライブ決め打ちで
#
PowerShell "&{ Add-WindowsFeature Server-GUI-Mgmt-Infra,Server-GUI-Shell -Source (\"WIM:{0}\sources\install.wim:4\" -F (Get-CimInstance Win32_CDROMDrive | Sort-Object Drive)[0].Drive) -Restart }"
#
# Windows Server 2016 TPにGUI Shellをインストールするやーつ(真面目版)
# いまのところTPは英語版しかないから警告メッセージは適当な英語で
#
if( -not (Get-WindowsFeature -Name Server-GUI-Shell).Installed )
{
if( (Get-WindowsFeature -Name Server-GUI-Mgmt-Infra).Installed )
{
Add-WindowsFeature Server-GUI-Shell -Restart
}
else
{
# Server-GUI-Mgmt-Infraがインストールされてない場合はwimからインストールする。
# ソースドライブはとりあえず最初にあるCDドライブ決め打ちで。
$Drive = (Get-CimInstance Win32_CDROMDrive | Sort-Object Drive)
if($null -eq $Drive)
{
Write-Warning "Source drive was not found."
}
else
{
if( $Drive -is [Array] )
{
$DriveName = $Drive[0].Drive
}
else
{
$DriveName = $Drive.Drive
}
$SourcePath = "$DriveName\sources\install.wim"
if( Test-Path $SourcePath -PathType Leaf )
{
Add-WindowsFeature Server-GUI-Mgmt-Infra, Server-GUI-Shell -Source ("WIM:{0}:4" -F $SourcePath) -Restart
}
else
{
Write-Warning ("WIM file {0} was not found." -F $SourcePath)
}
}
}
}
@stknohg
Copy link
Author

stknohg commented Nov 20, 2015

TP4ではServer-GUI-Mgmt-Infra、Server-GUI-Shellの両機能が無くこのスクリプトは動作しません。
GUIの有無はインストール時にしか決めれない様です。

@stknohg
Copy link
Author

stknohg commented Sep 28, 2016

GA版でもServer-GUI-Mgmt-Infra、Server-GUI-Shellの両機能が無くこのスクリプトは動作しません。
Windows Server 2016では、GUIの有無はインストール時にしか決めれない仕様となっています。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment