部署 Nano ServerDeploy Nano Server

適用於︰Windows Server 2016Applies To: Windows Server 2016


從 Windows Server 版本 1709 開始,Nano Server 僅以容器基礎 OS 映像的形式來提供。Starting in Windows Server, version 1709, Nano Server will be available only as a container base OS image. 請查看 Nano Server 的變更以了解這代表的意義。Check out Changes to Nano Server to learn what this means.

本主題涵蓋部署 Nano Server 映像所需的資訊,相較於<Nano Server 快速入門>主題中的簡單範例,這些映像更能夠依照您的需求加以自訂。This topic covers information you need to deploy Nano Server images that are more customized to your needs compared to the simple examples in the Nano Server Quick Start topic. 您可以找到下列相關資訊:使用您需要的所有功能來建立自訂 Nano Server 映像、從 VHD 或 WIM 安裝 Nano Server 映像、編輯檔案、使用網域、透過幾個方法來處理套件,以及使用伺服器角色。You'll find information about making a custom Nano Server image with exactly the features you want, installing Nano Server images from VHD or WIM, editing files, working with domains, dealing with packages by several methods, and working with server roles.

Nano Server Image BuilderNano Server Image Builder

Nano Server Image Builder 工具可協助您在圖形化介面的輔助下,建立自訂 Nano Server 映像和可開機的 USB 媒體。The Nano Server Image Builder is a tool that helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. 根據您提供的輸入,它會產生可重複使用的 PowerShell 指令碼,讓您輕鬆地自動並一致安裝執行 Windows Server 2016 Datacenter 或 Standard Edition 的 Nano Server。Based on the inputs you provide, it generates reusable PowerShell scripts that allow you easily automate consistent installations of Nano Server running either Windows Server 2016 Datacenter or Standard editions.

下載中心取得工具。Obtain the tool from the Download Center.

此工具也需要 Windows 評定及部署套件 (ADK)The tool also requires Windows Assessment and Deployment Kit (ADK).

Nano Server Image Builder 會建立 VHD、VHDX 或 ISO 格式的自訂 Nano Server 映像,以及可開機的 USB 媒體,來部署 Nano Server 或偵測伺服器的硬體設定。Nano Server Image Builder creates customized Nano Server images in VHD, VHDX or ISO formats and can create bootable USB media to deploy Nano server or detect the hardware configuration of a server. 它也可以執行下列作業:It also can do the following:

  • 接受授權條款Accept the license terms
  • 建立 VHD、VHDX 或 ISO 格式Create VHD, VHDX or ISO formats
  • 新增伺服器角色Add server roles
  • 新增裝置驅動程式Add device drivers
  • 設定機器名稱、系統管理員密碼、記錄檔路徑和時區Set machine name, administrator password, logfile path, and timezone
  • 使用現有的 Active Directory 帳戶或收集到的網域加入 Blob 來加入網域Join a domain by using an existing Active Directory account or a harvested domain-join blob
  • 啟用 WinRM 以在本機子網路外部進行通訊Enable WinRM for communication outside the local subnet
  • 啟用虛擬區域網路識別碼並設定靜態 IP 位址Enable Virtual LAN IDs and configure static IP addresses
  • 快速插入新的服務套件Inject new servicing packages on the fly
  • 新增要在處理 unattend.xml 之後執行的 setupcomplete.cmd 或其他客戶指令碼Add a setupcomplete.cmd or other customer scripts to run after the unattend.xml is processed
  • 啟用緊急管理服務 (EMS) 以進行序列埠主控台存取Enable Emergency Management Services (EMS) for serial port console access
  • 啟用開發服務,以啟用已用測試簽署的驅動程式和未簽署的應用程式、PowerShell 預設殼層Enable development services to enable test signed drivers and unsigned applications, PowerShell default shell
  • 啟用透過序列、USB、TCP/IP 或 IEEE 1394 通訊協定進行偵錯Enable debugging over serial, USB, TCP/IP, or IEEE 1394 protocols
  • 使用 WinPE 建立 USB 媒體,這將會分割伺服器,並安裝 Nano 映像Create USB media using WinPE that will partition the server and install the Nano image
  • 使用 WinPE 建立 USB 媒體,這將會偵測您現有的 Nano Server 硬體設定,並報告記錄檔中和螢幕上的所有詳細資料。Create USB media using WinPE that will detect your existing Nano Server hardware configuration and report all the details in a log and on-screen. 這包括網路介面卡、MAC 位址和韌體類型 (BIOS 或 UEFI)。This includes network adapters, MAC addresses, and firmware Type (BIOS or UEFI). 此偵測程序也會列出沒有 Server Core 驅動程式套件隨附驅動程式之系統和裝置上的所有磁碟區清單。The detection process will also list all of the volumes on the system and the devices that do not have a driver included in the Server Core drivers package.

如果您不熟悉上述任何作業,請檢閱本主題的其餘部分及其他 Nano Server 主題,以準備好提供工具所需的資訊。If any of these are unfamiliar to you, review the remainder of this topic and the other Nano Server topics so that you'll be prepared to provide the tool with the information it will need.

建立自訂 Nano Server 映像Creating a custom Nano Server image

在 Windows Server 2016 中,Nano Server 會透過實體媒體散發,您將在媒體中找到 NanoServer 資料夾,其中包含 .wim 映像及名為 Packages 的子資料夾。For Windows Server 2016, Nano Server is distributed on the physical media, where you will find a NanoServer folder; this contains a .wim image and a subfolder called Packages. 這是您用來將伺服器角色和功能新增至 VHD 映像,並接著開機到此映像的套件檔案。It is these package files that you use to add server roles and features to the VHD image, which you then boot to.

您也可以找出並使用 PackageManagement (OneGet) PowerShell 模組的 NanoServerPackage 提供者安裝這些套件。You can also find and install these packages with the NanoServerPackage provider of PackageManagement (OneGet) PowerShell module. 請參閱本主題的<線上安裝角色和功能>一節。See the "Installing roles and features online" section of this topic.

下表顯示此版 Nano Server 中可用的角色和功能,以及將安裝其套件的 Windows PowerShell 選項。This table shows the roles and features that are available in this release of Nano Server, along with the Windows PowerShell options that will install the packages for them. 有些套件可透過自己的 Windows PowerShell 參數 (例如 -Compute) 直接安裝;其他套件則藉由將套件名稱傳遞至 -Package 參數進行安裝 (可在逗號分隔清單中結合)。Some packages are installed directly with their own Windows PowerShell switches (such as -Compute); others you install by passing package names to the -Package parameter, which you can combine in a comma-separated list. 您可以使用 Get-NanoServerPackage Cmdlet 動態地列出可用的套件。You can dynamically list available packages using the Get-NanoServerPackage cmdlet.

角色或功能Role or feature 選項Option
Hyper-V 角色 (包括 NetQoS)Hyper-V role (including NetQoS) -Compute-Compute
容錯移轉叢集與其他元件,於此表後詳述Failover Clustering and other components, detailed after this table -Clustering-Clustering
各種網路介面卡和存放控制器的基本驅動程式。Basic drivers for a variety of network adapters and storage controllers. 這是 Windows Server 2016 之 Server Core 安裝隨附的同一組驅動程式。This is the same set of drivers included in a Server Core installation of Windows Server 2016. -OEMDrivers-OEMDrivers
檔案伺服器角色和其他存放元件,於此表後詳述File Server role and other storage components, detailed after this table -Storage-Storage
Windows Defender,包括預設簽章檔案Windows Defender, including a default signature file -Defender-Defender
反轉轉寄站以與應用程式相容,例如 Ruby、Node.js 等通用應用程式架構。Reverse forwarders for application compatibility, for example common application frameworks such as Ruby, Node.js, etc. 現在預設會包含Now included by default
DNS 伺服器角色DNS Server role -Package Microsoft-NanoServer-DNS-Package-Package Microsoft-NanoServer-DNS-Package
PowerShell 預期狀態設定 (DSC)PowerShell Desired State Configuration (DSC) -Package Microsoft-NanoServer-DSC-Package-Package Microsoft-NanoServer-DSC-Package
附註: 如需完整詳細資料,請參閱在 Nano Server 上使用 DSCNote: For full details, see Using DSC on Nano Server.
Internet Information Server (IIS)Internet Information Server (IIS) -Package Microsoft-NanoServer-IIS-Package-Package Microsoft-NanoServer-IIS-Package
附註: 如需使用 IIS 的詳細資料,請參閱 Nano Server 上的 IISNote: See IIS on Nano Server for details about working with IIS.
Windows 容器的主機支援Host support for Windows Containers -Containers-Containers
System Center Virtual Machine Manager 代理程式System Center Virtual Machine Manager agent -Package Microsoft-NanoServer-SCVMM-Package-Package Microsoft-NanoServer-SCVMM-Package
-Package Microsoft-NanoServer-SCVMM-Compute-Package-Package Microsoft-NanoServer-SCVMM-Compute-Package
附註︰ 只有在監視 Hyper-V 時才能使用 SCVMM 計算套件。Note: Use the SCVMM Compute package only if you are monitoring Hyper-V. 對於 VMM 中的超融合部署,您應該也指定 -Storage 參數。For hyper-converged deployments in VMM, you should also specify the -Storage parameter. 如需詳細資料,請參閱 VMM 文件For more details, see the VMM documentation.
System Center Operations Manager 代理程式System Center Operations Manager agent 個別安裝。Installed separately. 請參閱 System Center Operations Manager 文件,如需詳細資訊,在https://technet.microsoft.com/en-us/system-center-docs/om/manage/install-agent-on-nano-server。See the System Center Operations Manager documentation for more details at https://technet.microsoft.com/en-us/system-center-docs/om/manage/install-agent-on-nano-server.
資料中心橋接 (包括 DCBQoS)Data Center Bridging (including DCBQoS) -Package Microsoft-NanoServer-DCB-Package-Package Microsoft-NanoServer-DCB-Package
在虛擬機器上部署Deploying on a virtual machine -Package Microsoft-NanoServer-Guest-Package-Package Microsoft-NanoServer-Guest-Package
在實體機器上部署Deploying on a physical machine - Package Microsoft-NanoServer-Host-Package- Package Microsoft-NanoServer-Host-Package
BitLocker、信賴平台模組 (TPM)、磁碟區加密、平台識別、加密提供者,以及其他與安全啟動相關的功能BitLocker, trusted platform module (TPM), volume encryption, platform identification, cryptography providers, and other functionality related to secure startup -Package Microsoft-NanoServer-SecureStartup-Package-Package Microsoft-NanoServer-SecureStartup-Package
Hyper-V 支援受防護的 VMHyper-V support for Shielded VMs -Package Microsoft-NanoServer-ShieldedVM-Package-Package Microsoft-NanoServer-ShieldedVM-Package
附註: 此套件僅於 Nano Server 的 Datacenter 版本提供。Note: This package is only available for the Datacenter edition of Nano Server.
簡易網路管理通訊協定 (SNMP) 代理程式Simple Network Management Protocol (SNMP) agent -Package Microsoft-NanoServer-SNMP-Agent-Package.cab-Package Microsoft-NanoServer-SNMP-Agent-Package.cab
注意: 不包含在 Windows Server 2016 安裝媒體。Note: Not included with Windows Server 2016 installation media. 僅限線上存取。Available online only. 如需詳細資料,請參閱線上安裝角色和功能See Installing roles and features online for details.
IPHelper 服務,使用 IPv6 轉換技術(6to4、ISATAP、Proxy 連接埠和 Teredo)和 IP-HTTPS 提供通道連接IPHelper service which provides tunnel connectivity using IPv6 transition technologies (6to4, ISATAP, Port Proxy, and Teredo), and IP-HTTPS -Package Microsoft-NanoServer-IPHelper-Service-Package.cab-Package Microsoft-NanoServer-IPHelper-Service-Package.cab
注意: 不包含在 Windows Server 2016 安裝媒體。Note: Not included with Windows Server 2016 installation media. 僅限線上存取。Available online only. 如需詳細資料,請參閱線上安裝角色和功能See Installing roles and features online for details.


當您使用這些選項安裝套件時,也會根據選取的伺服器媒體地區設定一併安裝對應的語言套件。When you install packages with these options, a corresponding language pack is also installed based on selected server media locale. 您可以在針對映像地區設定命名之子資料夾中的安裝媒體上,找到可用的語言套件及其地區設定縮寫。You can find the available language packs and their locale abbreviations in the installation media in subfolders named for the locale of the image.


當您使用 -Storage 參數安裝檔案服務時,實際上不會啟用檔案服務。When you use the -Storage parameter to install File Services, File Services is not actually enabled. 請使用伺服器管理員,從遠端電腦啟用此功能。Enable this feature from a remote computer with Server Manager.

-Clustering 參數所安裝的容錯移轉叢集項目Failover Clustering items installed by the -Clustering parameter

  • 容錯移轉叢集角色Failover Clustering role
  • VM 容錯移轉叢集VM Failover Clustering
  • 儲存空間直接存取 (S2D)Storage Spaces Direct (S2D)
  • 存放裝置服務品質Storage Quality of Service
  • 磁碟區複寫叢集Volume Replication Clustering
  • SMB 見證服務SMB Witness Service

-Storage 參數所安裝的檔案與儲存項目File and storage items installed by the -Storage parameter

  • 檔案伺服器角色File Server role
  • 重複資料刪除Data Deduplication
  • 多重路徑 I/O,包括 Microsoft 裝置特定模組 (MSDSM) 的驅動程式Multipath I/O, including a driver for Microsoft Device-Specific Module (MSDSM)
  • ReFS (v1 與 v2)ReFS (v1 and v2)
  • iSCSI 啟動器 (但非 iSCSI 目標)iSCSI Initiator (but not iSCSI Target)
  • 儲存體複本Storage Replica
  • 存放裝置管理服務與 SMI-S 支援Storage Management Service with SMI-S support
  • SMB 見證服務SMB Witness Service
  • 動態磁碟區Dynamic Volumes
  • 基本 Windows 儲存體提供者 (適用於 Windows 存放管理)Basic Windows storage providers (for Windows Storage Management)

安裝 Nano Server VHDInstalling a Nano Server VHD

此範例會建立 GPT 型 VHDX 映像,該映像具有指定的電腦名稱,並包含透過網路共用上的 Nano Server 安裝媒體啟動的 Hyper-V 客體驅動程式。This example creates a GPT-based VHDX image with a given computer name and including Hyper-V guest drivers, starting with Nano Server installation media on a network share. 在提升權限的 Windows PowerShell 命令提示字元中,從下列 Cmdlet 開始:In an elevated Windows PowerShell prompt, start with this cmdlet:

Import-Module <Server media location>\NanoServer\NanoServerImageGenerator; New-NanoServerImage -DeploymentType Guest -Edition Standard -MediaPath \\Path\To\Media\server_en-us -BasePath .\Base -TargetPath .\FirstStepsNano.vhdx -ComputerName FirstStepsNano

此 Cmdlet 將會完成下列所有工作:The cmdlet will accomplish all of these tasks:

  1. 選取 Standard 作為基底版本Select Standard as a base edition

  2. 提示您輸入系統管理員密碼Prompt you for the Administrator password

  3. 將 \\Path\To\Media\server_en-us 中的安裝媒體複製到 .\BaseCopy installation media from \\Path\To\Media\server_en-us into .\Base

  4. 將 WIM 映像轉換成 VHD。Convert the WIM image to a VHD. (目標路徑引數的副檔名決定要建立第 1 代虛擬機器的 MBR 型 VHD,還是第 2 代虛擬機器的 GPT 型 VHDX)。(The file extension of the target path argument determines whether it creates an MBR-based VHD for Generation 1 virtual machines versus a GPT-based VHDX for Generation 2 virtual machines.)

  5. 將產生的 VHD 複製到 .\FirstStepsNano.vhdxCopy the resulting VHD into .\FirstStepsNano.vhdx

  6. 依照指定為映像設定系統管理員密碼Set the Administrator password for the image as specified

  7. 將映像的電腦名稱設定為 FirstStepsNanoSet the computer name of the image to FirstStepsNano

  8. 安裝 Hyper-V 客體驅動程式Install the Hyper-V guest drivers

最後會產生 .\FirstStepsNano.vhdx 的映像。All of this results in an image of .\FirstStepsNano.vhdx.

此 Cmdlet 會在執行時產生記錄檔,並在完成時告訴您此記錄檔的所在位置。The cmdlet generates a log as it runs and will let you know where this log is located once it is finished. 隨附指令碼所完成的 WIM 至 VHD 轉換會在 %TEMP%\Convert-WindowsImage\<GUID> 中產生自己的記錄檔 (其中 <GUID> 是每個轉換工作階段的唯一識別碼)。The WIM-to-VHD conversion accomplished by the companion script generates its own log in %TEMP%\Convert-WindowsImage\<GUID> (where <GUID> is a unique identifier per conversion session).

只要您使用相同的基底路徑,就可以在每次執行此 Cmdlet 時省略媒體路徑參數,因為它會使用從基底路徑快取的檔案。As long as you use the same base path, you can omit the media path parameter every time you run this cmdlet, since it will use cached files from the base path. 如果您未指定基底路徑,此 Cmdlet 會在 TEMP 資料夾中產生預設路徑。If you don't specify a base path, the cmdlet will generate a default one in the TEMP folder. 不過,如果您想要使用不同的來源媒體但相同的基底路徑,則應該指定媒體路徑參數。If you want to use different source media, but the same base path, you should specify the media path parameter, however.


您現在可以選擇指定 Nano Server 版本,建置 Standard 或 Datacenter Edition。You now have the option to specify the Nano Server edition to build either the Standard or Datacenter edition. 請使用 -Edition 參數來指定 StandardDatacenter Edition。Use the -Edition parameter to specify Standard or Datacenter editions.

一旦您擁有現成的映像,就可以視需要使用 Edit-NanoServerImage Cmdlet 加以修改。Once you have an existing image, you can modify it as needed using the Edit-NanoServerImage cmdlet.

如果未指定電腦名稱,就會隨機產生名稱。If you do not specify a computer name, a random name will be generated.

安裝 Nano Server WIMInstalling a Nano Server WIM

  1. NanoServerImageGenerator 資料夾從 Windows Server 2016 ISO 中的 \NanoServer 資料夾複製到您電腦上的本機資料夾。Copy the NanoServerImageGenerator folder from the \NanoServer folder in the Windows Server 2016 ISO a local folder on your computer.
  2. 以系統管理員身分啟動 Windows PowerShell,將目錄變更為您放置 NanoServerImageGenerator 資料夾的資料夾,然後使用 Import-Module .\NanoServerImageGenerator -Verbose 匯入模組。Start Windows PowerShell as an administrator, change directory to the folder where you placed the NanoServerImageGenerator folder and then import the module with Import-Module .\NanoServerImageGenerator -Verbose.


    您可能需要調整 Windows PowerShell 執行原則。You might have to adjust the Windows PowerShell execution policy. Set-ExecutionPolicy RemoteSigned 應該適用。should work well.

若要建立 Nano Server 映像作為 Hyper-V 主機,請執行下列命令:To create a Nano Server image to serve as a Hyper-V host, run the following:

New-NanoServerImage -Edition Standard -DeploymentType Host -MediaPath <path to root of media> -BasePath .\Base -TargetPath .\NanoServerPhysical\NanoServer.wim -ComputerName <computer name> -OEMDrivers -Compute -Clustering


  • -MediaPath 是包含 Windows Server 2016 之 DVD 媒體或 ISO 映像的根目錄。-MediaPath is the root of the DVD media or ISO image containing Windows Server 2016 .
  • -BasePath 會包含 Nano Server 二進位檔複本,讓您在未來執行時可以使用 New-NanoServerImage -BasePath,而不需要指定 -MediaPath。-BasePath will contain a copy of the Nano Server binaries, so you can use New-NanoServerImage -BasePath without having to specify -MediaPath in future runs.
  • -TargetPath 會包含產生的 .wim 檔案,其中包含您選取的角色和功能。-TargetPath will contain the resulting .wim file containing the roles & features you selected. 請務必指定 .wim 副檔名。Make sure to specify the .wim extension.
  • -Compute 會新增 Hyper-V 角色。-Compute adds the Hyper-V role.
  • -OemDrivers 會新增一些常見的驅動程式。-OemDrivers adds a number of common drivers.

系統將提示您輸入系統管理員密碼。You will be prompted to enter an administrator password.

如需詳細資訊,請執行 Get-Help New-NanoServerImage -FullFor more information, run Get-Help New-NanoServerImage -Full.

開機到 WinPE,並確保剛才建立的 .wim 檔案可從 WinPE 存取Boot into WinPE and ensure that the .wim file just created is accessible from WinPE. (例如,您可以將 .wim 檔案複製到 USB 快閃磁碟機上可開機的 WinPE 映像)。(You could, for example, copy the .wim file to a bootable WinPE image on a USB flash drive.)

啟動 WinPE 之後,使用 Diskpart.exe 來準備目標電腦的硬碟。Once WinPE boots, use Diskpart.exe to prepare the target computer's hard drive. 執行下列 Diskpart 命令 (如果未使用 UEFI 和 GPT,請相應地修改):Run the following Diskpart commands (modify accordingly, if you're not using UEFI & GPT):


這些命令將會刪除硬碟上的所有資料。These commands will delete all data on the hard drive.

Select disk 0Select disk 0
Convert GPTConvert GPT
Create partition efi size=100Create partition efi size=100
Format quick FS=FAT32 label="System"Format quick FS=FAT32 label="System"
Assign letter="s"Assign letter="s"
Create partition msr size=128Create partition msr size=128
Create partition primaryCreate partition primary
Format quick FS=NTFS label="NanoServer"Format quick FS=NTFS label="NanoServer"
Assign letter="n"Assign letter="n"
List volumeList volume

套用 Nano Server 映像 (調整 .wim 檔案的路徑):Apply the Nano Server image (adjust the path of the .wim file):

Dism.exe /apply-image /imagefile:.\NanoServer.wim /index:1 /applydir:n:\Dism.exe /apply-image /imagefile:.\NanoServer.wim /index:1 /applydir:n:\
Bcdboot.exe n:\Windows /s s:Bcdboot.exe n:\Windows /s s:

取出 DVD 媒體或 USB 磁碟機,然後使用 Wpeutil.exe Reboot 重新啟動您的系統Remove the DVD media or USB drive and reboot your system with Wpeutil.exe Reboot

編輯本機和遠端 Nano Server 上的檔案Editing files on Nano Server locally and remotely

在任一情況下,連線到 Nano Server,例如透過 Windows PowerShell 遠端執行功能。In either case, connect to Nano Server, such as with Windows PowerShell remoting.

連線到 Nano Server 之後,您可以藉由將檔案的相對或絕對路徑傳遞至 psEdit 命令,來編輯位於本機電腦上的檔案,例如:Once you've connected to Nano Server, you can edit a file residing on your local computer by passing the file's relative or absolute path to the psEdit command, for example:
psEdit C:\Windows\Logs\DISM\dism.log or psEdit .\myScript.ps1

藉由使用 Enter-PSSession -ComputerName "" -Credential ~\Administrator 啟動遠端工作階段,再將檔案的相對或絕對路徑傳遞至 psEdit 命令,來編輯位於遠端 Nano Server 上的檔案,如下所示:Edit a file residing on the remote Nano Server by starting a remote session with Enter-PSSession -ComputerName "" -Credential ~\Administrator and then passing the file's relative or absolute path to the psEdit command like this:
psEdit C:\Windows\Logs\DISM\dism.log

線上安裝角色和功能Installing roles and features online


如果您是從媒體或線上存放庫安裝選用的 Nano Server 套件,它並不會包含最新的安全性問題修正。If you install an optional Nano Server package from media or online repository, it won't have recent security fixes included. 若要避免選用套件和基本作業系統之間的版本不符,您應該在安裝選用套件之後和重新啟動伺服器之前,安裝最新的累計更新To avoid a version mismatch between the optional packages and base operating system, you should install the latest cumulative update immediately after installing any optional packages and before restarting the server.

從套件存放庫安裝角色和功能Installing roles and features from a package repository

您可以使用 PackageManagement PowerShell 模組的 NanoServerPackage 提供者,從線上套件存放庫尋找及安裝 Nano Server 套件。You can find and install Nano Server packages from the online package repository by using the NanoServerPackage provider of the PackageManagement PowerShell module. 若要安裝此提供者,請使用下列 Cmdlet:To install this provider, use these cmdlets:

Install-PackageProvider NanoServerPackage
Import-PackageProvider NanoServerPackage


如果您在執行 Install-PackageProvider 期間發生錯誤,請檢查您已安裝最新的累積更新 (KB3206632 或更新版本),或使用 Save-Module,如下所示:If you experience errors when running Install-PackageProvider, check that you have installed the latest cumulative update (KB3206632 or later), or use Save-Module as follows:

Save-Module -Path "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Name NanoServerPackage -MinimumVersion
Import-PackageProvider NanoServerPackage

安裝且匯入此提供者後,您便可使用特地設計用來與 Nano Server 套件搭配使用的 Cmdlet 搜尋、下載並安裝 Nano Server 套件。Once this provider is installed and imported, you can search for, download, and install Nano Server packages using cmdlets designed specifically for working with Nano Server packages:


您也可使用泛型 PackageManagement Cmdlet 並指定 NanoServerPackage 提供者:You can also use the generic PackageManagement cmdlets and specify the NanoServerPackage provider:

Find-Package -ProviderName NanoServerPackage
Save-Package -ProviderName NanoServerPackage
Install-Package -ProviderName NanoServerPackage
Get-Package -ProviderName NanoServerPackage

若要在 Nano Server 上搭配 Nano Server 套件使用上述任何 Cmdlet,請新增 -ProviderName NanoServerPackageTo use any of these cmdlets with Nano Server packages on Nano Server, add -ProviderName NanoServerPackage. 如果您未新增 -ProviderName 參數,PackageManagement 將會逐一查看所有提供者。If you don't add the -ProviderName parameter, PackageManagement will iterate all of the providers. 如需這些 Cmdlet 的詳細資料,請執行 Get-Help <cmdlet>For more details on these cmdlets, run Get-Help <cmdlet>. 以下為部分常見的使用範例:Here are some common usage examples:

搜尋 Nano Server 套件Searching for Nano Server packages

您可以使用 Find-NanoServerPackageFind-Package -ProviderName NanoServerPackage 搜尋並傳回線上存放庫中可用的 Nano Server 套件清單。You can use either Find-NanoServerPackage or Find-Package -ProviderName NanoServerPackage to search for and return a list of Nano Server packages that are available in the online repository. 例如,您可以取得所有最新套件的清單:For example, you can get a list of all the latest packages:


執行 Find-Package -ProviderName NanoServerPackage -DisplayCulture 會顯示所有可用的文化特性。Running Find-Package -ProviderName NanoServerPackage -DisplayCulture displays all available cultures.

如果您需要特定地區設定版本 (例如美國英文),您可以使用 Find-NanoServerPackage -Culture en-usIf you need a specific locale version, such as US English, you could use Find-NanoServerPackage -Culture en-us or
Find-Package -ProviderName NanoServerPackage -Culture en-us Find-Package -Culture en-us -DisplayCultureor Find-Package -Culture en-us -DisplayCulture.

若要依套件名稱尋找特定套件,請使用 -Name 參數。To find a specific package by package name, use the -Name parameter. 此參數也接受萬用字元。This parameter also accepts wildcards. 例如,若要尋找名稱中有 VMM 的所有套件,請使用 Find-NanoServerPackage -Name *VMM*Find-Package -ProviderName NanoServerPackage -Name *VMM*For example, to find all packages with VMM in the name, use Find-NanoServerPackage -Name *VMM* or Find-Package -ProviderName NanoServerPackage -Name *VMM*.

您可以使用 -RequiredVersion、-MinimumVersion 或 -MaximumVersion 參數來尋找特定版本。You can find a particular version with the -RequiredVersion, -MinimumVersion, or -MaximumVersion parameters. 若要尋找所有可用的版本,請使用 -AllVersions。To find all available versions, use -AllVersions. 否則,只會傳回最新版本。Otherwise, only the latest version is returned. 例如:Find-NanoServerPackage -Name *VMM* -RequiredVersion 10.0.14393.0For example: Find-NanoServerPackage -Name *VMM* -RequiredVersion 10.0.14393.0. 或者,針對所有版本:Or, for all versions: Find-Package -ProviderName NanoServerPackage -Name *VMM* -AllVersions

安裝 Nano Server 套件Installing Nano Server packages

您可以使用 Install-NanoServerPackageInstall-Package -ProviderName NanoServerPackage,將 Nano Server 套件 (包括其任何相依性套件) 安裝到本機 Nano Server 或離線映像。You can install a Nano Server package (including its dependency packages, if any) to Nano Server either locally or an offline image with either Install-NanoServerPackage or Install-Package -ProviderName NanoServerPackage. 兩者皆接受來自管道的輸入。Both of these accept input from the pipeline.

若要將最新版 Nano Server 套件安裝到線上 Nano Server,請使用 Install-NanoServerPackage -Name Microsoft-NanoServer-Containers-PackageInstall-Package -Name Microsoft-NanoServer-Containers-PackageTo install the latest version of a Nano Server package to an online Nano Server, use either Install-NanoServerPackage -Name Microsoft-NanoServer-Containers-Package or Install-Package -Name Microsoft-NanoServer-Containers-Package. PackageManagement 將會使用 Nano Server 的文化特性。PackageManagement will use the culture of the Nano Server.

您可以將 Nano Server 套件安裝到離線映像,同時指定特定版本和文化特性,如下所示:You can install a Nano Server package to an offline image while specifying a particular version and culture, like this:

Install-NanoServerPackage -Name Microsoft-NanoServer-DCB-Package -Culture de-de -RequiredVersion 10.0.14393.0 -ToVhd C:\MyNanoVhd.vhd


Install-Package -Name Microsoft-NanoServer-DCB-Package -Culture de-de -RequiredVersion 10.0.14393.0 -ToVhd C:\MyNanoVhd.vhd

以下是以管道方式將套件搜尋結果傳送至安裝 Cmdlet 的一些範例:Here are some examples of pipelining package search results to the installation cmdlet:

Find-NanoServerPackage *dcb* | Install-NanoServerPackage 會尋找名稱中有 "dcb" 的任何套件,然後加以安裝。finds any packages with "dcb" in the name and then installs them.

Find-Package *nanoserver-compute-* | Install-Package 會尋找名稱中有 "nanoserver-compute-" 的套件,然後加以安裝。finds packages with "nanoserver-compute-" in the name and installs them.

Find-NanoServerPackage -Name *nanoserver-compute* | Install-NanoServerPackage -ToVhd C:\MyNanoVhd.vhd 會尋找名稱中有 "compute" 的套件,然後安裝到離線映像。finds packages with "compute" in the name and installs them to an offline image.

Find-Package -ProviderName NanoserverPackage *nanoserver-compute-* | Install-Package -ToVhd C:\MyNanoVhd.vhd 會對名稱中有 "nanoserver-compute-" 的所有套件執行相同的動作。does the same thing with any package that has "nanoserver-compute-" in the name.

下載 Nano Server 套件Downloading Nano Server packages

Save-NanoServerPackage Save-Package 可讓您下載套件,並加以儲存而不進行安裝。or Save-Package allow you to download packages and save them without installing them. 兩個 Cmdlet 皆接受來自管道的輸入。Both cmdlets accept input from the pipeline.

例如,若要下載 Nano Server 套件並將其儲存至與萬用字元路徑相符的目錄,請使用 Save-NanoServerPackage -Name Microsoft-NanoServer-DNS-Package -Path C:\。在此範例中未指定 -Culture,因此會使用本機電腦的文化特性。For example, to download and save a Nano Server package to a directory that matches the wildcard path, use Save-NanoServerPackage -Name Microsoft-NanoServer-DNS-Package -Path C:\ In this example, -Culture wasn't specified, so the culture of the local machine will be used. 而且未指定任何版本,因此會儲存最新版本。No version was specified, so the latest version will be saved.

Save-Package -ProviderName NanoServerPackage -Name Microsoft-NanoServer-IIS-Package -Path C:\ -Culture it-IT -MinimumVersion 10.0.14393.0 會儲存義大利文語言和地區設定的特定版本。saves a particular version and for the Italian language and locale.

您可以透過管道傳送搜尋結果,如下列範例所示:You can send search results through the pipeline as in these examples:

Find-NanoServerPackage -Name *containers* -MaximumVersion 10.2 -MinimumVersion 1.0 -Culture es-ES | Save-NanoServerPackage -Path C:\


Find-Package -ProviderName NanoServerPackage -Name *shield* -Culture es-ES | Save-Package -Path

清查所安裝的套件Inventory installed packages

您可以使用 Get-Package 探索安裝了哪些 Nano Server 套件。You can discover which Nano Server packages are installed with Get-Package. 例如,使用 Get-Package -ProviderName NanoserverPackage 查看 Nano Server 上有哪些套件。For example, see which packages are on Nano Server with Get-Package -ProviderName NanoserverPackage.

若要檢查在離線映像中所安裝的 Nano Server 套件,請執行 Get-Package -ProviderName NanoserverPackage -FromVhd C:\MyNanoVhd.vhdTo check the Nano Server packages that are installed in an offline image, run Get-Package -ProviderName NanoserverPackage -FromVhd C:\MyNanoVhd.vhd.

從本機來源安裝角色和功能Installing roles and features from local source

雖然建議離線安裝伺服器角色和其他套件,但在容器案例中,您可能需要在線上 (Nano Server 正在執行時) 安裝這些項目。Though offline installation of server roles and other packages is recommended, you might need to install them online (with the Nano Server running) in container scenarios. 若要這樣做,請執行下列步驟:To do this, follow these steps:

  1. 將 Packages 資料夾從安裝媒體複製到執行中的本機 Nano Server (例如複製到 C:\packages)。Copy the Packages folder from the installation media locally to the running Nano Server (for example, to C:\packages).

  2. 在另一部電腦上建立新的 Unattend.xml 檔案,然後將它複製到 Nano Server。Create a new Unattend.xml file on another computer and then copy it to Nano Server. 您可以將此 XML 內容複製並貼到您建立的 XML 檔案 (此範例示範如何安裝 IIS 套件):You can copy and paste this XML content into the XML file you created (this example shows installing the IIS package):

<?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">  
        <package action="install">  
            <assemblyIdentity name="Microsoft-NanoServer-IIS-Feature-Package" version="10.0.14393.0" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" />  
            <source location="c:\packages\Microsoft-NanoServer-IIS-Package.cab" />  
        <package action="install">  
            <assemblyIdentity name="Microsoft-NanoServer-IIS-Feature-Package" version="10.0.14393.0" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="en-US" />  
            <source location="c:\packages\en-us\Microsoft-NanoServer-IIS-Package_en-us.cab" />  
    <cpi:offlineImage cpi:source="" xmlns:cpi="urn:schemas-microsoft-com:cpi" />  
  1. 在您建立 (或複製) 的新 XML 檔案中,將 C:\packages 修改為您複製套件內容的目的地目錄。In the new XML file you created (or copied), edit C:\packages to the directory you copied the content of Packages to.

  2. 切換至具有新建立之 XML 檔案的目錄,然後執行Switch to the directory with the newly created XML file and run

    dism /online /apply-unattend:.\unattend.xmldism /online /apply-unattend:.\unattend.xml

  3. 執行下列命令,確認已正確安裝該套件及其關聯的語言套件:Confirm that the package and its associated language pack is installed correctly by running:

    dism /online /get-packagesdism /online /get-packages

    您應該會看到 "Package Identity : Microsoft-NanoServer-IIS-Package~31bf3856ad364e35~amd64~en-US~10.0.10586.0" 列出兩次,一次針對 Release Type : Language Pack,另一次針對 Release Type : Feature Pack。You should see "Package Identity : Microsoft-NanoServer-IIS-Package~31bf3856ad364e35~amd64~en-US~10.0.10586.0" listed twice, once for Release Type : Language Pack and once for Release Type : Feature Pack.

自訂現有的 Nano Server VHDCustomizing an existing Nano Server VHD

您可以使用 Edit-NanoServerImage Cmdlet 來變更現有 VHD 的詳細資料,如下列範例所示:You can change the details of an existing VHD by using the Edit-NanoServerImage cmdlet, as in this example:

Edit-NanoServerImage -BasePath .\Base -TargetPath .\BYOVHD.vhd

此 Cmdlet 與 New-NanoServerImage 的功能相同,但會變更現有的映像,而不是將 WIM 轉換成 VHD。This cmdlet does the same things as New-NanoServerImage, but changes the existing image instead of converting a WIM to a VHD. 它與 New-NanoServerImage 支援相同的參數,但 -MediaPath 和 -MaxSize 則為例外,因此必須使用這兩個參數建立初始 VHD,才能使用 Edit-NanoServerImage 進行變更。It supports the same parameters as New-NanoServerImage with the exception of -MediaPath and -MaxSize, so the initial VHD must have been created with those parameters before you can make changes with Edit-NanoServerImage.

您可以使用 New-NanoServerImage 和 Edit-NanoServerImage 完成其他工作Additional tasks you can accomplish with New-NanoServerImage and Edit-NanoServerImage

加入網域Joining domains

New-NanoServerImage 提供兩種加入網域的方法,這兩個方法都需要離線網域佈建,但其中一個方法會收集 Blob 來完成加入。New-NanoServerImage offers two methods of joining a domain; both rely on offline domain provisioning, but one harvests a blob to accomplish the join. 在此範例中,此 Cmdlet 會從本機電腦為 Contoso 網域收集網域 Blob (這當然必須是 Contoso 網域的一部分),然後使用此 Blob 執行映像的離線佈建:In this example, the cmdlet harvests a domain blob for the Contoso domain from the local computer (which of course must be part of the Contoso domain), then it performs offline provisioning of the image using the blob:

New-NanoServerImage -Edition Standard -DeploymentType Host -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\JoinDomHarvest.vhdx -ComputerName JoinDomHarvest -DomainName Contoso

當此 Cmdlet 完成時,您應該會在 Active Directory 電腦清單中找到名為 "JoinDomHarvest" 的電腦。When this cmdlet completes, you should find a computer named "JoinDomHarvest" in the Active Directory computer list.

您也可以在未加入網域的電腦上使用此 Cmdlet。You can also use this cmdlet on a computer that is not joined to a domain. 若要這樣做,請從任何加入網域的電腦收集 Blob,然後將 Blob 自行提供給此 Cmdlet。To do this, harvest a blob from any computer that is joined to the domain, and then provide the blob to the cmdlet yourself. 請注意,當您從其他電腦收集這類 Blob 時,Blob 已包含該電腦的名稱;因此,如果您嘗試新增 -ComputerName 參數,則會產生錯誤。Note that when you harvest such a blob from another computer, the blob already includes that computer's name--so if you try to add the -ComputerName parameter, an error will result.

您可以使用下列命令收集 Blob:You can harvest the blob with this command:

/Domain Contoso/Domain Contoso
/Machine JoiningDomainsNoHarvest/Machine JoiningDomainsNoHarvest
/SaveFile JoiningDomainsNoHarvest.djoin/SaveFile JoiningDomainsNoHarvest.djoin

使用收集到的 Blob執行 New-NanoServerImage:Run New-NanoServerImage using the harvested blob:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\JoinDomNoHrvest.vhd -DomainBlobPath .\Path\To\Domain\Blob\JoinDomNoHrvestContoso.djoin

如果您在網域中已有一個節點,其電腦名稱與未來的 Nano Server 同名,您可以新增 -ReuseDomainNode 參數來重複使用此電腦名稱。In the event that you already have a node in the domain with the same computer name as your future Nano Server, you could reuse the computer name by adding the -ReuseDomainNode parameter.

新增其他驅動程式Adding additional drivers

Nano Server 提供一個套件,其中包括適用於各種網路介面卡和存放控制器的一組基本驅動程式;您的網路介面卡適用的驅動程式可能未包含在內。Nano Server offers a package that includes a set of basic drivers for a variety of network adapters and storage controllers; it's possible that drivers for your network adapters might not be included. 您可以使用下列步驟來尋找運作中系統的驅動程式、將驅動程式解壓縮,再新增至 Nano Server 映像。You can use these steps to find drivers in a working system, extract them, and then add them to the Nano Server image.

  1. 在您將執行 Nano Server 的實體電腦上安裝 Windows Server 2016。Install Windows Server 2016 on the physical computer where you will run Nano Server.
  2. 開啟裝置管理員,並找出下列類別的裝置:Open Device Manager and identify devices in the following categories:
  3. 網路介面卡Network adapters
  4. 存放控制器Storage controllers
  5. 磁碟機Disk drives
  6. 針對這些類別的每個裝置,以滑鼠右鍵按一下裝置名稱,然後按一下 /[內容/]For each device in these categories, right-click the device name, and click Properties. 在開啟的對話方塊中,按一下 /[驅動程式/] 索引標籤,然後按一下 /[驅動程式詳細資料/]In the dialog that opens, click the Driver tab, and then click Driver Details.
  7. 記下出現之驅動程式檔案的檔名和路徑。Note the filename and path of the driver file that appears. 例如,假設驅動程式檔案為 e1i63x64.sys,且位於 C:\Windows\System32\Drivers 中。For example, let's say the driver file is e1i63x64.sys, which is in C:\Windows\System32\Drivers.
  8. 在命令提示字元中,搜尋驅動程式檔案並搜尋具有 dir e1i*.sys /s /b 的所有執行個體。In a command prompt, search for the driver file and search for all instances with dir e1i*.sys /s /b. 在此範例中,驅動程式檔案也會位於路徑 C:\Windows\System32\DriverStore\FileRepository\net1ic64.inf_amd64_fafa7441408bbecd\e1i63x64.sys 中。In this example, the driver file is also present in the path C:\Windows\System32\DriverStore\FileRepository\net1ic64.inf_amd64_fafa7441408bbecd\e1i63x64.sys.
  9. 在提升權限的命令提示字元中,瀏覽至 Nano Server VHD 所在的目錄,然後執行下列命令︰md mountdirIn an elevated command prompt, navigate to the directory where the Nano Server VHD is and run the following commands: md mountdir

    dism\dism /Mount-Image /ImageFile:.\NanoServer.vhd /Index:1 /MountDir:.\mountdirdism\dism /Mount-Image /ImageFile:.\NanoServer.vhd /Index:1 /MountDir:.\mountdir

    dism\dism /Add-Driver /image:.\mountdir /driver: C:\Windows\System32\DriverStore\FileRepository\net1ic64.inf_amd64_fafa7441408bbecddism\dism /Add-Driver /image:.\mountdir /driver: C:\Windows\System32\DriverStore\FileRepository\net1ic64.inf_amd64_fafa7441408bbecd

    dism\dism /Unmount-Image /MountDir:.\MountDir /Commitdism\dism /Unmount-Image /MountDir:.\MountDir /Commit

  10. 針對您需要的每個驅動程式檔案重複這些步驟。Repeat these steps for each driver file you need.


在您保留驅動程式的資料夾中,必須有 SYS 檔案和對應的 INF 檔案。In the folder where you keep your drivers, both the SYS files and corresponding INF files must be present. 此外,Nano Server 只支援已簽署的 64 位元驅動程式。Also, Nano Server only supports signed, 64-bit drivers.

插入驅動程式Injecting drivers

Nano Server 提供一個套件,其中包括適用於各種網路介面卡和存放控制器的一組基本驅動程式;您的網路介面卡適用的驅動程式可能未包含在內。Nano Server offers a package that includes a set of basic drivers for a variety of network adapters and storage controllers; it's possible that drivers for your network adapters might not be included. 您可以使用此語法,讓 New-NanoServerImage 搜尋目錄中是否有可用的驅動程式,並將其插入 Nano Server 映像:You can use this syntax to have New-NanoServerImage search the directory for available drivers and inject them into the Nano Server image:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\InjectingDrivers.vhdx -DriverPath .\Extra\Drivers


在您保留驅動程式的資料夾中,必須有 SYS 檔案和對應的 INF 檔案。In the folder where you keep your drivers, both the SYS files and corresponding INF files must be present. 此外,Nano Server 只支援已簽署的 64 位元驅動程式。Also, Nano Server only supports signed, 64-bit drivers.

使用 -DriverPath 參數,您也可以將路徑陣列傳遞至驅動程式 .inf 檔案:Using the -DriverPath parameter, you can also pass a array of paths to driver .inf files:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\InjectingDrivers.vhdx -DriverPath .\Extra\Drivers\netcard64.inf

使用 WinRM 進行連線Connecting with WinRM

若要使用 Windows 遠端管理 (WinRM) 從位於不同子網路的其他電腦連線到 Nano Server 電腦,請針對 Nano Server 映像上的連入 TCP 流量開啟連接埠 5985。To be able to connect to a Nano Server computer using Windows Remote Management (WinRM) (from another computer that is not on the same subnet), open port 5985 for inbound TCP traffic on the Nano Server image. 使用下列 Cmdlet:Use this cmdlet:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\ConnectingOverWinRM.vhd -EnableRemoteManagementPort

設定靜態 IP 位址Setting static IP addresses

若要設定 Nano Server 映像使用靜態 IP 位址,請先使用 Get-NetAdapter、netsh 或 Nano Server 修復主控台,尋找您要修改之介面的名稱或索引。To configure a Nano Server image to use static IP addresses, first find the name or index of the interface you want to modify by using Get-NetAdapter, netsh, or the Nano Server Recovery Console. 請使用 -Ipv6Address、-Ipv6Dns、-Ipv4Address、-Ipv4SubnetMask、-Ipv4Gateway 和 -Ipv4Dns 參數來指定此設定,如下列範例所示:Use the -Ipv6Address, -Ipv6Dns, -Ipv4Address, -Ipv4SubnetMask, -Ipv4Gateway and -Ipv4Dns parameters to specify the configuration, as in this example:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\StaticIpv4.vhd -InterfaceNameOrIndex Ethernet -Ipv4Address -Ipv4SubnetMask -Ipv4Gateway -Ipv4Dns

自訂映像大小Custom image size

您可以設定 Nano Server 映像,使用 -MaxSize 參數來動態擴充 VHD 或 VHDX,如下列範例所示:You can configure the Nano Server image to be a dynamically expanding VHD or VHDX with the -MaxSize parameter, as in this example:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\BigBoss.vhd -MaxSize 100GB

嵌入自訂資料Embedding custom data

若要將您自己的指令碼或二進位檔嵌入 Nano Server 映像,請使用 -CopyPath 參數傳遞要複製的檔案和目錄陣列。To embed your own script or binaries in the Nano Server image, use the -CopyPath parameter to pass an array of files and directories to be copied. -CopyPath 參數也可接受雜湊表來指定檔案及路徑的目的地路徑。The -CopyPath parameter can also accept a hashtable to specify the destination path for files and directories.

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\BigBoss.vhd -CopyPath .\tools

在初次開機之後執行自訂命令Running custom commands after the first boot

若要將自訂命令當做 setupcomplete.cmd 的一部分來執行,請使用 -SetupCompleteCommand 參數傳遞命令陣列:To run custom commands as part of setupcomplete.cmd, use the -SetupCompleteCommand parameter to pass an array of commands:

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\NanoServer.wim -SetupCompleteCommand @("echo foo", "echo bar")

將執行自訂 PowerShell 指令碼作為建立映像的一部份Running custom PowerShell scripts as part of image creation

若要將執行自訂 PowerShell 指令碼作為映像建立程序的一部份,請使用 -OfflineScriptPath 參數將路徑陣列傳遞至 .ps1 指令碼。To run custom PowerShell scripts as part of the image creation process, use the -OfflineScriptPath parameter to pass an array of paths to .ps1 scripts. 若這些指令碼接受引數,則使用 -OfflineScriptArgument 將其他引數的雜湊表傳遞至指令碼。If those scripts take arguments, use the -OfflineScriptArgument to pass a hashtable of additional arguments to the scripts.

New-NanoServerImage -DeploymentType Host -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\NanoServer.wim -OfflineScriptPath C:\MyScripts\custom.ps1 -OfflineScriptArgument @{Param1="Value1"; Param2="Value2"}

開發案例的支援Support for development scenarios

如果您想要在 Nano Server 上進行開發和測試,您可以使用 -Development 參數。If you want to develop and test on Nano Server, you can use the -Development parameter. 這會將 PowerShell 作為預設本機殼層啟用、啟用未簽署驅動程式的安裝、複製偵錯工具二進位檔、開啟偵錯用的連接埠、啟用測試簽署,以及啟用 AppX 套件的安裝,而不需要開發人員授權:This will enable PowerShell as the default local shell, enable installation of unsigned drivers, copy debugger binaries, open a port for debugging, enable test signing, and enable installation of AppX packages without a developer license:

New-NanoServerImage -DeploymentType Guest -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\NanoServer.wim -Development

自訂自動安裝檔案Custom unattend file

如果您想要使用自己的自動安裝檔案,請使用 -UnattendPath 參數:If you want to use your own unattend file, use the -UnattendPath parameter:

New-NanoServerImage -DeploymentType Guest -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\NanoServer.wim -UnattendPath \\path\to\unattend.xml

在此自動安裝檔案中指定系統管理員密碼或電腦名稱,將會覆寫由 -AdministratorPassword 和 -ComputerName 設定的值。Specifying an administrator password or computer name in this unattend file will override the values set by -AdministratorPassword and -ComputerName.


Nano Server 不支援透過自動安裝檔案設定 TCP/IP 設定。Nano Server does not support setting TCP/IP settings via unattend files. 您可以使用 Setupcomplete.cmd 設定 TCP/IP 設定。You can use Setupcomplete.cmd to configure TCP/IP settings.

收集記錄檔Collecting log files

若您要在建立映像期間收集記錄檔,請使用 -LogPath 參數指定所有記錄檔的複製目標目錄。If you want to collect the log files during image creation, use the -LogPath parameter to specify a directory where all the log files are copied.

New-NanoServerImage -DeploymentType Guest -Edition Standard -MediaPath \\Path\To\Media\en_us -BasePath .\Base -TargetPath .\NanoServer.wim -LogPath C:\Logs


New-NanoServerImage 及 Edit-NanoServerImage 上的部分參數僅供內部使用,且可放心忽略。Some parameters on New-NanoServerImage and Edit-NanoServerImage are for internal use only and can be safely ignored. 這包括 -SetupUI 及 -Internal 參數。These include the -SetupUI and -Internal parameters.

安裝應用程式和驅動程式Installing apps and drivers

Windows Server 應用程式安裝程式Windows Server App installer

Windows Server 應用程式 (WSA) 安裝程式為 Nano Server 提供可靠的安裝選項。Windows Server App (WSA) installer provides a reliable installation option for Nano Server. 因為 Nano Server 不支援 Windows Installer (MSI),所以 WSA 也是適用於非 Microsoft 產品的唯一安裝技術。Since Windows Installer (MSI) is not supported on Nano Server, WSA is also the only installation technology available for non-Microsoft products. WSA 利用 Windows 應用程式封裝技術,其設計目的是為了能夠使用宣告式資訊清單,安全可靠地安裝及服務應用程式。WSA leverages Windows app package technology designed to install and service applications safely and reliably, using a declarative manifest. 該技術擴充 Windows 應用程式封裝安裝程式,以便支援 Windows Server 特定的擴充功能,但具有 WSA 不支援安裝驅動程式的限制。It extends the Windows app package installer to support Windows Server-specific extensions, with the limitation that WSA does not support installing drivers.

在 Nano Server 上建立及安裝 WSA 套件同時需要套件的發行者和取用者執行步驟。Creating and installing a WSA package on Nano Server involves steps for both the publisher and the consumer of the package.

套件發行者應該執行下列步驟:The package publisher should do the following:

  1. 安裝 Windows 10 SDK,其中包括建立 WSA 套件所需的工具︰MakeAppx、MakeCert、Pvk2Pfx、SignTool。Install Windows 10 SDK, which includes the tools needed to create a WSA package: MakeAppx, MakeCert, Pvk2Pfx, SignTool.
  2. 宣告資訊清單︰遵循 WSA 資訊清單延伸結構描述建立資訊清單檔案 AppxManifest.xml。Declare a manifest: Follow the WSA manifest extension schema to create the manifest file, AppxManifest.xml.
  3. 使用 MakeAppx 工具建立 WSA 套件。Use the MakeAppx tool to create a WSA package.
  4. 使用 MakeCertPvk2Pfx 工具建立憑證,然後使用 Signtool 簽署套件。Use MakeCert and Pvk2Pfx tools to create the certificate, and then use Signtool to sign the package.

接下來,套件取用者應該執行下列步驟:Next, the package consumer should follow these steps:

  1. 執行 Import-Certificate PowerShell Cmdlet,將上述步驟 4 中的發行者憑證匯入 Nano Server,其 certStoreLocation 位於 "Cert:\LocalMachine\TrustedPeople"。Run the Import-Certificate PowerShell cmdlet to import the publisher's certificate from Step 4 above to Nano Server with the certStoreLocation at "Cert:\LocalMachine\TrustedPeople". 例如:For example: Import-Certificate -FilePath ".\xyz.cer" -CertStoreLocation "Cert:\LocalMachine\TrustedPeople"
  2. 執行 Add-AppxPackage PowerShell Cmdlet 在 Nano Server 上安裝 WSA 套件,以在 Nano Server 上安裝應用程式。Install the app on Nano Server by running the Add-AppxPackage PowerShell cmdlet to install a WSA package on Nano Server. 例如:For example: Add-AppxPackage wsaSample.appx

用於建立應用程式的其他資源Additional resources for creating apps

WSA 是 Windows 應用程式封裝技術的伺服器擴充功能 (但未裝載於 Microsoft Store)。WSA is server extension of Windows app package technology (though it is not hosted in Microsoft Store). 如果您想要使用 WSA 發行應用程式,下列主題將協助您熟悉應用程式封裝管道:If you want to publish apps with WSA,these topics will help you familiarize youself with the app package pipeline:

在 Nano Server 上安裝驅動程式Installing drivers on Nano Server

您可以使用 INF 驅動程式套件,在 Nano Server 上安裝非 Microsoft 驅動程式。You can install non-Microsoft drivers on Nano Server by using INF driver packages. 其中包括隨插即用 (PnP) 驅動程式套件和檔案系統篩選器驅動程式套件。These include both Plug-and-Play (PnP) driver packages and File System Filter driver packages. Nano Server 目前不支援網路篩選器驅動程式。Network Filter drivers are not currently supported on Nano Server.

PnP 和檔案系統篩選器驅動程式套件必須遵循通用驅動程式需求和安裝程序,以及一般驅動程式套件方針 (例如簽署)。Both PnP and File System Filter driver packages must follow the Universal driver requirements and installation process, as well as general driver package guidelines such as signing. 相關說明請參閱下列位置:They are documented at these locations:

離線安裝驅動程式套件Installing driver packages offline

您可以透過 DISM.exeDISM PowerShell Cmdlet,將支援的驅動程式套件安裝到離線 Nano Server。Supported driver packages can be installed on Nano Server offline via DISM.exe or DISM PowerShell cmdlets.

線上安裝驅動程式套件Installing driver packages online

您可以使用 PnpUtil,將 PnP 驅動程式套件安裝到線上 Nano Server。PnP driver packages can be installed to Nano Server online by using PnpUtil. Nano Server 目前不支援非 PnP 驅動程式套件的線上驅動程式安裝。Online driver installation for non-PnP driver packages is not currently supported on Nano Server.

將 Nano Server 加入網域Joining Nano Server to a domain

在線上將 Nano Server 加入網域To add Nano Server to a domain online

  1. 使用下列命令,從網域中已執行 Windows Threshold Server 的電腦收集資料 Blob:Harvest a data blob from a computer in the domain that is already running Windows Threshold Server using this command:

    djoin.exe /provision /domain <domain-name> /machine <machine-name> /savefile .\odjblob

    這會將資料 Blob 儲存在名為 "odjblob" 的檔案中。This saves the data blob in a file called "odjblob".

  2. 使用下列命令,將 "odjblob" 檔案複製到 Nano Server 電腦:Copy the "odjblob" file to the Nano Server computer with these commands:

    net use z: \\<Nano Server 的 IP 位址>\c$net use z: \\<ip address of Nano Server>\c$


    如果 net use 命令失敗,您可能需要調整 Windows 防火牆規則。If the net use command fails, you probably need to adjust Windows Firewall rules. 若要這樣做,請先開啟提升權限的命令提示字元、啟動 Windows PowerShell,然後使用 Windows PowerShell 遠端執行功能並搭配下列命令連線到 Nano Server 電腦:To do this, first open an elevated command prompt, start Windows PowerShell and then connect to the Nano Server computer with Windows PowerShell Remoting with these commands:

    Set-Item WSMan:\localhost\Client\TrustedHosts "<IP address of Nano Server>"

    $ip = "<ip address of Nano Server>"

    Enter-PSSession -ComputerName $ip -Credential $ip\Administrator

    出現提示時,提供系統管理員密碼,然後執行下列命令來設定防火牆規則:When prompted, provide the Administrator password, then run this command to set the firewall rule:

    netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yesnetsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes

    使用 Exit-PSSession 結束 Windows PowerShell,然後重試 net use 命令。Exit Windows PowerShell with Exit-PSSession, and then retry the net use command. 如果成功,請繼續將 "odjblob" 檔案內容複製到 Nano Server。If successful, continue copying the "odjblob" file contents to the Nano Server.

    md z:\Tempmd z:\Temp

    copy odjblob z:\Tempcopy odjblob z:\Temp

  3. 檢查您要加入 Nano Server 的網域,並確定已設定 DNS。Check the domain you want to join Nano Server to and ensure that DNS is configured. 此外,請確認網域或網域控制站的名稱解析如預期般運作正常。Also, verify that name resolution of the domain or a domain controller works as expected. 若要這樣做,請開啟提升權限的命令提示字元、啟動 Windows PowerShell,然後使用 Windows PowerShell 遠端執行功能並搭配下列命令連線到 Nano Server 電腦:To do this, open an elevated command prompt, start Windows PowerShell and then connect to the Nano Server computer with Windows PowerShell remoting with these commands:

    Set-Item WSMan:\localhost\Client\TrustedHosts "<IP address of Nano Server>"

    $ip = "<ip address of Nano Server>"

    Enter-PSSession -ComputerName $ip -Credential $ip\Administrator

    出現提示時,提供系統管理員密碼。When prompted, provide the Administrator password. Nano Server 上無法使用 nslookup,因此您可以使用 Resolve-DNSName 確認名稱解析。Nslookup is not available on Nano Server, so you can verify name resolution with Resolve-DNSName.

  4. 如果名稱解析成功,則在相同的 Windows PowerShell 工作階段中,執行下列命令以加入網域:If name resolution succeeds, then in the same Windows PowerShell session, run this command to join the domain:

    djoin /requestodj /loadfile c:\Temp\odjblob /windowspath c:\windows /localos

  5. 重新啟動 Nano Server 電腦,然後結束 Windows PowerShell 工作階段:Restart the Nano Server computer, and then exit the Windows PowerShell session:

    shutdown /r /t 5


  6. 將 Nano Server 加入網域之後,請將網域使用者帳戶新增至 Nano Server 上的 Administrators 群組。After you have joined Nano Server to a domain, add the domain user account to the Administrators group on the Nano Server.

  7. 為了確保安全,請使用下列命令,從信任主機清單中移除 Nano Server:For security, remove the Nano Server from the trusted hosts list with this command: Set-Item WSMan:\localhost\client\TrustedHosts ""

以一個步驟加入網域的替代方法Alternate method to join a domain in one step

首先,使用下列命令,從執行 Windows Threshold Server 並已在網域中的另一部電腦收集資料 Blob:First, harvest the data blob from another computer running Windows Threshold Server that is already in your domain using this command:

djoin.exe /provision /domain <domain-name> /machine <machine-name> /savefile .\odjblob

開啟檔案 "odjblob" (或許使用 [記事本])、複製其內容,然後將內容貼到下列 Unattend.xml 檔案的 <AccountData> 區段中。Open the file "odjblob" (perhaps in Notepad), copy its contents, and then paste the contents into the <AccountData> section of the Unattend.xml file below.

將此 Unattend.xml 檔案放到 C:\NanoServer 資料夾中,然後使用下列命令來掛接 VHD 並套用 offlineServicing 區段中的設定:Put this Unattend.xml file into the C:\NanoServer folder, and then use the following commands to mount the VHD and apply the settings in the offlineServicing section:

dism\dism /Mount-ImagemediaFile:.\NanoServer.vhd /Index:1 /MountDir:.\mountdirdism\dism /Mount-ImagemediaFile:.\NanoServer.vhd /Index:1 /MountDir:.\mountdir

dism\dismmedia:.\mountdir /Apply-Unattend:.\unattend.xmldism\dismmedia:.\mountdir /Apply-Unattend:.\unattend.xml

建立 "Panther" 資料夾 (供 Windows 系統用於存放安裝期間的檔案;如需詳細資訊,請參閱 Windows 7, Windows Server 2008 R2, and Windows Vista setup log file locations (Windows 7、Windows Server 2008 R2 和 Windows Vista 安裝記錄檔位置)),將 Unattend.xml 檔案複製到其中,然後使用下列命令取消掛接 VHD:Create a "Panther" folder (used by Windows systems for storing files during setup; see Windows 7, Windows Server 2008 R2, and Windows Vista setup log file locations if you're curious), copy the Unattend.xml file to it, and then unmount the VHD with these commands:

md .\mountdir\windows\panthermd .\mountdir\windows\panther

copy .\unattend.xml .\mountdir\windows\panthercopy .\unattend.xml .\mountdir\windows\panther

dism\dism /Unmount-Image /MountDir:.\mountdir /Commitdism\dism /Unmount-Image /MountDir:.\mountdir /Commit

第一次從此 VHD 啟動 Nano Server 時,將會套用其他設定。The first time you boot Nano Server from this VHD, the other settings will be applied.

將 Nano Server 加入網域之後,請將網域使用者帳戶新增至 Nano Server 上的 Administrators 群組。After you have joined Nano Server to a domain, add the domain user account to the Administrators group on the Nano Server.

在 Nano Server 上使用伺服器角色Working with server roles on Nano Server

在 Nano Server 上使用 Hyper-VUsing Hyper-V on Nano Server

Hyper-V 在 Nano Server 上的運作方式與在 Server Core 模式的 Windows Server 上相同,但有兩個例外:Hyper-V works the same on Nano Server as it does on Windows Server in Server Core mode, with two exceptions:

  • 您必須從遠端執行所有管理,而且管理電腦必須與 Nano Server 執行相同組建的 Windows Server。You must perform all management remotely and the management computer must be running the same build of Windows Server as the Nano Server. 舊版 Hyper-V 管理員或 Hyper-V Windows PowerShell Cmdlet 將無法運作。Older versions of Hyper-V Manager or Hyper-V Windows PowerShell cmdlets will not work.

  • RemoteFX 不適用。RemoteFX is not available.

在此版本中,Hyper-V 的這些功能已確認:In this release, these features of Hyper-V have been verified:

  • 啟用 Hyper-VEnabling Hyper-V

  • 建立第 1 代和第 2 代虛擬機器Creation of Generation 1 and Generation 2 virtual machines

  • 建立虛擬交換器Creation of virtual switches

  • 啟動虛擬機器並執行 Windows 客體作業系統Starting virtual machines and running Windows guest operating systems

  • Hyper-V 複本Hyper-V Replica

如果您想要執行虛擬機器的即時移轉、在 SMB 共用上建立虛擬機器,或將現有 SMB 共用上的資源連線到現有的虛擬機器,請務必正確設定驗證。If you want to perform a live migration of virtual machines, create a virtual machine on an SMB share, or connect resources on an existing SMB share to an existing virtual machine, it is vital that you configure authentication correctly. 您有兩個選項可執行這項作業:You have two options for doing this:

限制委派Constrained delegation

限制委派的運作方式與舊版完全相同。Constrained delegation works exactly the same as in previous releases. 如需詳細資訊,請參閱下列文章:Refer to these articles for more information:


首先,參閱本主題的<使用 Windows PowerShell 遠端執行功能>一節來啟用及測試 CredSSP。First, refer to the "Using Windows PowerShell remoting" section of this topic to enable and test CredSSP. 然後,您可以在管理電腦上使用 Hyper-V 管理員,然後選取 [連線為其他使用者] 選項。Then, on the management computer, you can use Hyper-V Manager and select the option to "connect as another user." Hyper-V 管理員將會使用 CredSSP。Hyper-V Manager will use CredSSP. 即使您使用目前的帳戶,也應該執行這項操作。You should do this even if you are using your current account.

Hyper-V 的 Windows PowerShell Cmdlett 可以使用 CimSession 或 Credential 參數,這兩個參數都適用於 CredSSP。Windows PowerShell cmdlets for Hyper-V can use CimSession or Credential parameters, either of which work with CredSSP.

在 Nano Server 上使用容錯移轉叢集Using Failover Clustering on Nano Server

容錯移轉叢集在 Nano Server 上的運作方式與在 Server Core 模式的 Windows Server 上相同,但請注意下列事項:Failover clustering works the same on Nano Server as it does on Windows Server in Server Core mode, but keep these caveats in mind:

  • 必須使用容錯移轉叢集管理員或 Windows PowerShell 從遠端管理這些叢集。Clusters must be managed remotely with Failover Cluster Manager or Windows PowerShell.

  • 所有 Nano Server 叢集節點都必須都加入相同的網域,類似於 Windows Server 中的叢集節點。All Nano Server cluster nodes must be joined to the same domain, similar to cluster nodes in Windows Server.

  • 此網域帳戶必須具有所有 Nano Server 節點的系統管理員權限,就像是 Windows Server 中的叢集節點一樣。The domain account must have Administrator privileges on all Nano Server nodes, as with cluster nodes in Windows Server.

  • 所有命令都必須在提升權限的命令提示字元中執行。All commands must be run in an elevated command prompt.


此外,此版本不支援某些功能:Additionally, certain features are not supported in this release:

  • 您無法在本機 Nano Server 上透過 Windows PowerShell 執行容錯移轉叢集 Cmdlet。You cannot run failover clustering cmdlets on a local Nano Server through Windows PowerShell.
  • 將 Hyper-V 和檔案伺服器以外的角色叢集化。Clustering roles other than Hyper-V and File Server.

您會發現適用於管理容錯移轉叢集的下列 Windows PowerShell Cmdlet:You'll find these Windows PowerShell cmdlets useful in managing Failover clusters:

您可以使用下列命令建立新的叢集:You can create a new cluster with New-Cluster -Name <clustername> -Node <comma-separated cluster node list>

建立新的叢集之後,您應該在所有節點上執行 Set-StorageSetting -NewDiskPolicy OfflineSharedOnce you've established a new cluster, you should run Set-StorageSetting -NewDiskPolicy OfflineShared on all nodes.

使用下列命令,將其他節點新增至叢集:Add an additional node to the cluster with Add-ClusterNode -Name <comma-separated cluster node list> -Cluster <clustername>

使用下列命令,從叢集中移除節點:Remove a node from the cluster with Remove-ClusterNode -Name <comma-separated cluster node list> -Cluster <clustername>

使用下列命令,建立向外延展檔案伺服器:Create a Scale-Out File Server with Add-ClusterScaleoutFileServerRole -name <sofsname> -cluster <clustername>

您可以在 Microsoft.FailoverClusters.PowerShell 中找到用於容錯移轉叢集的其他 Cmdlett。You can find additional cmdlets for failover clustering at Microsoft.FailoverClusters.PowerShell.

在 Nano 伺服器上使用 DNS 伺服器Using DNS Server on Nano Server

若要提供 DNS 伺服器角色給 Nano Server,請將 Microsoft-NanoServer-DNS-Package 新增至映像 (請參閱本主題的<建立自訂 Nano Server 映像>一節。To provide Nano Server with the DNS Server role, add the Microsoft-NanoServer-DNS-Package to the image (see the "Creating a custom Nano Server image" section of this topic. 一旦 Nano Server 在執行中,請連線到此伺服器,然後從提升權限的 Windows PowerShell 主控台執行下列命令來啟用功能:Once the Nano Server is running, connect to it and run this command from and elevated Windows PowerShell console to enable the feature:

Enable-WindowsOptionalFeature -Online -FeatureName DNS-Server-Full-Role

在 Nano Server 上使用 IISUsing IIS on Nano Server

如需使用 Internet Information Services (IIS) 角色的步驟,請參閱 Nano Server 上的 IISFor steps to use the Internet Information Services (IIS) role, see IIS on Nano Server.

在 Nano Server上使用多重路徑 I/O (MPIO)Using MPIO on Nano Server

如需使用多重路徑 I/O (MPIO) 的步驟,請參閱 Nano Server 上的多重路徑 I/O (MPIO)For steps to use MPIO, see MPIO on Nano Server

在 Nano Server 上使用 SSHUsing SSH on Nano Server

如需如何在 Nano Server 上安裝及使用 SSH 的指示,請參閱 Win32-OpenSSH WikiFor instructions on how to install and use SSH on Nano Server with the OpenSSH project, see the Win32-OpenSSH wiki.

附錄︰將 Nano Server 加入網域的範例 Unattend.xml 檔案Appendix: Sample Unattend.xml file that joins Nano Server to a domain


將 "odjblob" 的內容貼到 Unattend 檔案之後,請務必刪除內容中的尾端空格。Be sure to delete the trailing space in the contents of "odjblob" once you paste it into the Unattend file.

<?xml version='1.0' encoding='utf-8'?>  
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="https://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  

  <settings pass="offlineServicing">  
    <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  

  <settings pass="oobeSystem">  
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  
      <TimeZone>Pacific Standard Time</TimeZone>  

  <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>