Auto create Nano server for ESXi with Powershell

Posted on Posted in Windows

I have recently played a little with Microsoft’s up coming Windows 2016 OS. One of the things I find very intriguing about Windows 2016 is Nano Server. It is the possibility to create a small and fast booting version of Windows. Nano server is JeOS (Just Enough OS), meaning that it all you need for the task ahead. Not more deploying 50GB+ servers with lots of features if you only need one. This equals faster boot times, smaller footprint on resources and smaller attack surface. All good things that IT has come to love from the Linux world. The only real down site is that to make it that small the Windows GUI has to go. But then who really needs that in this world of automation.

Currently in Technical Preview 5 (TP5), only a subset of Windows features are supported. Some of the most critical such as Active Directory has yet to be available on Nano Server which is a pity. Being able to deploy a small Nano Server with AD on it would be most welcome in most home labs and enterprises.

If you want your Nano Server to include any features these need to be specified. Microsoft calls the feature for packages. Adding the parameter ‘-packages <package>’ to the ‘New-NanoServerImage’ string, enables you to specify which packages to include in your Nano Server build. I say your build because the way this script work is that it will create a bootable VMDK which can be uploaded to your ESXi host and used as part of a new deployment of a VM or in VMware Workstation. If you want to look into which packages are available your can take a look at technet’s “Getting Started with Nano Server” guide.

What is Nano Server?
What is Nano Server?

Prerequisites

Before we continue there are a few thing needed to automate the task of creating a Nano Server VMDK with Powershell. When I first started out trying to create a Nano Server VMDK, I thought I could use VMware Workstation to do the convertion from VHD(x) to VMDK. VHD to VMDK works with VMware Workstation, but the VMDK is not bootable.  Nothing but a mere Nano Server installation which isn’t what I wanted. VHDx to VMDK can’t be handle by VMware Workstation unfortunately. Though the script still requires VMware Workstation it is only for drivers. An other tool for conversion was needed. Starwind Software to the rescue. With there StarWind V2V Converter it is possible to do the convertion from VHDx to VMDK. Besides doing the job via GUI or command line, it’s also free. Thanks guys!

 

Credit

This blog post might never had come to pass , if it were not for a few people which some of my work is based on. So before I continue I would like to give credit to those who deserve it.

 

Auto create Nano server for ESXi with Powershell

Now to the script. The script has a few variables that need to be correct for the script to work, the includes path to VMware Workstation and Starwind V2V Converter which both needs to be installed. Default working directory is  “C:\Temp\Windows Nano Server\” change it as it suites you and in that directory there need to be a folder name ISO with the Windows 2016 TP release named “Windows-Nano-Server-TP5.ISO”. You should go over the variables and make sure your are happy this the selections already made. As the script does clean up after it self please put it in its own folder, such as deletions doesn’t happen to unwanted files.

What you end up with is a VMDK and a flat file ready to be added to a newly created VM. Please look at Andreas Peetz‘s How to deploy Windows Nano Server (TP5) on vSphere guide for all the details.

All you have to do it make it work is follow the above guidelines and copy/paste the below into a Powershell console and the output will be a ready to run Nano Server on vSphere, in a matter of minutes without any user interaction.

As always the script below is available on Github. Enjoy

One thought on “Auto create Nano server for ESXi with Powershell

Leave a Reply

Your email address will not be published. Required fields are marked *