Last active
September 28, 2016 01:11
-
-
Save stknohg/1629d0832dd18ce12225 to your computer and use it in GitHub Desktop.
Windows Server 2016 TPにGUI Shellをインストールするやーつ(※GA版では使えないので注意)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 }" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GA版でもServer-GUI-Mgmt-Infra、Server-GUI-Shellの両機能が無くこのスクリプトは動作しません。
Windows Server 2016では、GUIの有無はインストール時にしか決めれない仕様となっています。