作業の合間に Nano Server をセットアップしようとしていて、下のエラーが出て失敗したのかと思ったらそうでもなかったりしていた件についてメモを。 ![]()
いろいろな方に情報をいただいて最終的には起動しました。
ご助言くださった方々、本当にありがとうございます!!
Nano Server のインストール方法については以下を参考にさせていただいています。
山市良版 Getting Started with Nano Server
Getting Started with Nano Server
Nano Server 取りあえずやってみた
冒頭の画面キャプチャのエラーですが、マルウェア対策のアップデータのエラーが一時的に画面に表示されているだけのようで無視してしまってよさそうです。
実際のエラーの内容は以下です。
------------------------------------------------------------------------------------- MpCmdRun: Command Line: "C:\Program Files\Windows Defender\MpCmdRun.exe" -IdleTask -TaskName WdCacheMaintenance Start Time: Sun May Starting RunCommandScStart: Idle Task - WdCacheMaintenance ERROR: Creating Idle Notifier Context Failed 80501002 MpCmdRun: End Time: Sun May 17 2015 21:15:15 -----------------------MpCmdRun: End Time: Sun May 17 2015 21:15:15 ------------------------------------------------------------------------------------- ------------------------------------------- erification ERROR: Creating Idle Notifier Context Failed 80501002 MpCmdRun: End Time: Sun May 17 2015 21:15:15 ------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- MpCmdRun: Command Line: "C:\Program Files\Windows Defender\MpCmdRun.exe" -EnableIntegrityServices Start Time: Sun May 17 2015 21:15:16 Integrity services enabled successfully. MpCmdRun: End Time: Sun May 17 2015 21:15:17 -------------------------------------------------------------------------------------
で、実際にはつながるのではというアドバイスをいただいたので、
Set-Item WSMan:\localhost\Client\TrustedHosts -Value * Enter-PSSession -ComputerName <IP アドレス> -Credential (Get-Credential -UserName Administrator -Message "Nano Server Connect")
をやったらさくっとつながりました…。
# SetupComplete.cmd のスペル間違ったり、環境作るのに使っていたスクリプトで追加書きと上書きを間違えたりという凡ミスの連発で想定通り動いていないだけでした。
第 2 世代の仮想マシンで動くかを確認したかったので、雑ですが以下のようなスクリプトで、VHDX を作ってテストをしていました。
Windows Server 2012 R2 + Gen2 のゲストで動くことがわかったのでよかったです。
![]()
$vhdxpath = "c:\temp\nanoserver.vhdx" # VHDX の出力先
$dismpath = "F:\sources\dism.exe" # TP2 に対応した DISM のパス (テスト時は TP2 のメディアから実行)
$packagepath = "F:\NanoServer" # Nano Server のイメージに使用するパッケージのパス
$WimConvertScript = "C:\temp\Convert-WindowsImage.ps1" # https://gallery.technet.microsoft.com/scriptcenter/Convert-WindowsImageps1-0fe23a8f から入手したスクリプト
# 応答ファイル
[xml]$UnattendXml = @"
<?xml version='1.0' encoding='utf-8'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<settings pass="offlineServicing">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<ComputerName>NanoServer1503</ComputerName>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<UserAccounts>
<AdministratorPassword>
<Value>Tuva</Value>
<PlainText>true</PlainText>
</AdministratorPassword>
</UserAccounts>
<TimeZone>Pacific Standard Time</TimeZone>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<RegisteredOwner>My Team</RegisteredOwner>
<RegisteredOrganization>My Corporation</RegisteredOrganization>
</component>
</settings>
</unattend>
"@
# Wim を VHDX に変換
& $WimConvertScript -SourcePath (Join-Path $packagepath "NanoServer.wim") -VHDFormat VHDX -VHDPartitionStyle GPT -Edition 1 -VHDPath $vhdxpath
# 変換した VHDX をマウント
Mount-DiskImage -ImagePath $vhdxpath
# VHDX をマウントしたドライブレターを取得
$vdisk = Get-PhysicalDisk | ?{$_.Model -like "Virtual Disk*"}
$vdiskdrive = Get-Partition -DiskNumber $vdisk.DeviceId
$vdiskdriveletter = "{0}:" -f ($vdiskdrive | ?{$_.PartitionNumber -eq "3"}).DriveLetter
# インストールするパッケージを指定。今回はゲスト上で動かすところを確認するため Guest Package のみをインストール
$InstallPackages = @(
"Microsoft-NanoServer-Guest-Package.cab";
#"Microsoft-NanoServer-Compute-Package.cab";
#"Microsoft-NanoServer-FailoverCluster-Package.cab";
#"Microsoft-NanoServer-OEM-Drivers-Package.cab";
#"Microsoft-NanoServer-Storage-Package.cab";
)
# パッケージの追加
foreach ($InstallPackage in $InstallPackages){
Invoke-Expression "$dismpath /Add-Package /PackagePath:$(Join-path $packagepath "Packages\$Installpackage") /Image:$vdiskdriveletter"
Invoke-Expression "$dismpath /Add-Package /PackagePath:$(Join-path $packagepath "Packages\en-us\$Installpackage") /Image:$vdiskdriveletter"
}
# SetupComplete.cmd の作成
if ((Test-Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts")) -eq $false){
New-Item -ItemType Directory -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts") | Out-Null
}
# タスクスケジューラーにコマンドを登録して 1 分間隔で IP を表示
Set-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\DisplayIP.cmd") -Value "@ECHO OFF" -Encoding Ascii
Add-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\DisplayIP.cmd") -Value "ECHO %DATE% %TIME%" -Encoding Ascii
Add-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\DisplayIP.cmd") -Value "ECHO %COMPUTERNAME%" -Encoding Ascii
Add-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\DisplayIP.cmd") -Value "ipconfig" -Encoding Ascii
Set-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\SetupComplete.cmd") -Value "@ECHO OFF" -Encoding Ascii
Add-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\SetupComplete.cmd") -Value 'schtasks.exe /create /ru "NT AUTHORITY\SYSTEM" /TN "Display IP" /TR "C:\windows\setup\scripts\displayIP.cmd" /SC MINUTE /mo 1 /F' -Encoding Ascii
Add-Content -Path (Join-Path $vdiskdriveletter "Windows\Setup\Scripts\SetupComplete.cmd") -Value "C:\windows\setup\scripts\DisplayIP.cmd" -Encoding Ascii
# 応答ファイルの配置
if ((Test-Path (Join-Path $vdiskdriveletter "Windows\Panther")) -eq $false){
New-Item -ItemType Directory -Path (Join-Path $vdiskdriveletter "Windows\Panther") | Out-Null
}
Set-Content -Path (Join-path $env:TEMP "unattend.xml") -Value $UnattendXml.InnerXml -Encoding Ascii
Copy-Item -Path (Join-path $env:TEMP "unattend.xml") (Join-Path $vdiskdriveletter "Windows\Panther")
Remove-Item -Path (Join-path $env:TEMP "unattend.xml")
# VHDX のマウント解除
Dismount-DiskImage $vhdxpath