Saturday, January 28, 2017

Creating a Nano Server Image

Installing Windows 2016 Nano server isn't simply adding the DVD and clicking next-next-finish, but it needs some preparation. The base nano image wim file is only 168MB, but that has no functionality in itself. More needs to be added through features, drivers and packages.

From a management workstation, mount the Windows 2016 ISO (i.e. doubleclick it, take note of the driveletter). On the ISO file you will see a NanoServer directory:


That directory has the NanoServer.wim file, Packages folder and a NanoServerImageGenerator folder. That last folder contains a PowerShell Module, which you need to import in an Administrator PowerShell window (which in my case is on the E: drive):

Import-Module E:\NanoServer\NanoServerImageGenerator\NanoServerImageGenerator.psm1

Now you should have a bunch of extra commands available:

PS C:\Users\Akos> get-command -Module *nano* | select Name

Name                
----                
Edit-NanoServerImage
Get-NanoServerPackage
New-NanoServerImage  

The New-NanoServerImage cmdlet is the one you will need to create a fully functional image. The options are a slew of information. I've created a splatted variable set below, otherwise the line becomes far too long for the blog ;-)

$Pwd = ConvertTo-SecureString -String "Pa$$w0rd!" -AsPlainText -Force

$Options = @{
    MediaPath = 'E:' #Location of DVD
    BasePath = 'D:\TMP\Base' #Location of install files
    TargetPath = 'D:\TMP\NanoWeb01.vhdx' #Where the vhdx will come
    ComputerName = 'NanoWeb01' #No idea, I think the computername..
    AdministratorPassword = "$Pwd" #A secure string password
    DeploymentType = 'Guest' #This will make it a vhdx file
    Edition = 'Standard' #Windows version (Standard or Datacenter)
    Package = 'Microsoft-NanoServer-IIS-Package' #Packages, in this case IIS
}

New-NanoServerImage -EnableRemoteManagementPort -Storage @Options

This example creates a VM called NanoWeb01, with a password of "Pa$$w0rd!", and has IIS installed. The switch "-EnableRemoteManagementPort" does what it says. You can then connect to it via PSRemoting. The switch "-Storage" allows the Nano server to have filesharing available. If you don't need that, you can let it go, but for testing it's nice to have. This VM is ready for Hyper-V, and is about 560MB as it is configured like this.

There are several packages you can choose from, which can be found by the Get-NanoServerPackage cmdlet:

PS C:\Users\Akos> Get-NanoServerPackage -MediaPath e:
Microsoft-NanoServer-Compute-Package
Microsoft-NanoServer-Containers-Package
Microsoft-NanoServer-DCB-Package
Microsoft-NanoServer-Defender-Package
Microsoft-NanoServer-DNS-Package
Microsoft-NanoServer-DSC-Package
Microsoft-NanoServer-FailoverCluster-Package
Microsoft-NanoServer-Guest-Package
Microsoft-NanoServer-Host-Package
Microsoft-NanoServer-IIS-Package
Microsoft-NanoServer-OEM-Drivers-Package
Microsoft-NanoServer-SCVMM-Compute-Package
Microsoft-NanoServer-SCVMM-Package
Microsoft-NanoServer-SecureStartup-Package
Microsoft-NanoServer-ShieldedVM-Package
Microsoft-NanoServer-SoftwareInventoryLogging-Package
Microsoft-NanoServer-Storage-Package

Next to this there are other switches too, of which a complete list and more info can be found on Microsoft's site. In all, Nano server takes a little work to get it running, but once it does, it starts in seconds.

Edit: You may have noticed the -Storage and -EnableRemoteManagementPort switches in my New-NanoServerImage command. I just saw in a different article, you can put them in the splatted options as well, by doing "Storage = $true" and the same for EnableRemoteManagementPort. You learn something new every day..

No comments:

Post a Comment