- Getting Started with Nano Server
- Charbel Nemnom
- 726字
- 2025-04-04 19:01:39
Building and customizing a Nano Server image using Windows PowerShell
First, you need to mount Windows Server 2016 ISO media on any Windows 10 or Windows Server 2016 machine.
Assuming the drive letter for the mounted image is E:
Run the following PowerShell cmdlet:
Copy "E:\NanoServer""C:\NanoServer" -Recurse
We are copying the NanoServer folder from the mounted ISO image into C:\NanoServer locally.
Import the NanoServerImageGenerator.psd1 PowerShell module by running the following command:
Import-Module "C:\NanoServer\ NanoServerImageGenerator\NanoServerImageGenerator.psd1" -Verbose

After importing the new PowerShell module using the -Verbose parameter, you will notice we have in fact imported three commands: New-NanoServerImage, Get-NanoServerPackages, and Edit-NanoServerImage:
- The New-NanoServerImage creates a new Nano Server image.
- The Edit-NanoServerImage makes changes to an existing image that you already built. For example, you have created an image that has the Hyper-V compute package and you have been using it for a while. Now, if you decide that you want to add the clustering role, then you can edit the image to add the clustering package instead of creating a new one.
- The Get-NanoServerPackages lists all supported packages on the media.
To generate a VHD(X) from NanoServer.WIM by using the New-NanoServerImage function, open Windows PowerShell as Administrator and run the following:
Cd C:\NanoServer
$Password = Read-Host -Prompt "Please specify local Administrator password" -AsSecureString
New-NanoServerImage -MediaPathE: `
-BasePathC:\NanoServer\ `
-TargetPathC:\NanoServer\NanoServer01.vhdx `
-DeploymentTypeGuest `
-EditionDatacenter `
-ComputerName"NANO-01" `
-AdministratorPassword$Password `
-InterfaceNameOrIndexEthernet `
-Ipv4Address192.168.1.10 `
-Ipv4SubnetMask255.255.255.0 `
-Ipv4Dns192.168.1.9 `
-Ipv4Gateway192.168.1.1 `
-EnableRemoteManagementPort `
-Verbose
Let's dive into the parameters that we used in this example:
- -MediaPath : This is the root of the DVD drive or the ISO image (E: in my case), where your media is.
- -BasePath: This is the local folder on your machine that you specify where the command is going to keep a copy of the Nano Server binaries. In other words, next time you use the command to create a Nano Server image, you don't have to use -MediaPath anymore. You can just use -BasePath, because it already has a copy of the binaries, so you will save the copy time.
- -TargetPath: This is the location path where you want to generate your final image. You can specify any folder you want, but make sure you specify the extension you want. In this example, we specified VHDX, because that was what I wanted. You can specify VHD, VHDX, or WIM as well.
- -DeploymentType: This is a very important parameter when you are generating a Nano image. This will be guest or host, depending on whether you want to deploy a virtual machine or a physical Nano Server. In this example, we specified guest; you can consider the guest the same as integration services in Hyper-V. Integration Services (also called integration services) are the set of synthetic drivers which allow a virtual machine to communicate with the host operating system.
- -Edition: This parameter helps you to choose a Standard or Datacenter edition. For more information about pricing and licensing for Windows Server 2016, please check the following link: https://www.microsoft.com/en-us/cloud-platform/windows-server-pricing.
- -ComputerName: This is the name of the Nano Server computer.
- -AdministratorPassword: This is the local Admin password (the one we specified at the beginning of the script).
- -InterfaceNameOrIndex: This parameter helps you to change the IP settings of a network adapter; you'll need to use this parameter in conjunction with the following IP parameters. The first NIC adapter will always be named Ethernet.
- -Ipv4Address, -Ipv4SubnetMask, -Ipv4Dns, -Ipv4Gateway-: are self-explanatory and enable the setting of static addresses; if you don't specify these parameters, Nano Server will look for the DHCP server on the network.
- -EnableRemoteManagementPort: This parameter opens port 5985 for inbound TCP connections for Windows Remote Management (WinRM) to manage Nano Server across different subnets.
After running the previous script, you will get a Nano Server VHDX image with just enough OS, without any role or feature added.
If you created a VHDX Nano image and you want to use this image in Hyper-V, please make sure to choose generation 2 virtual machine (this is very important). VHDX means generation 2, in this case, for Nano Server and VHD means generation 1. More on this in Chapter 3, Deploying Nano Server in a Virtual Machine and on Physical Hardware.