Using DeployImage and Windows PowerShell to Build a Nano Server: Part 5

Honorary Scripting Guy, Sean Kearney, is here today to show you one of my favorite pieces of my DeployImage module—building a piece of bootable USB media that has everything I need to deploy Nano Server.

Last week in the series, Build a PowerShell-Enabled Windows PE Key, I talkedl about building a Windows PE USB key with Windows PowerShell. This week, I explored how to use the new DeployImage module to build out Nano Server. Today we’re going to combine them.

Much of the work we did last week…well, that’s now simply a few cmdlets in the DeployImage module. We can now build out the custom WIM file with Windows PowerShell with the New-WindowsPEWim cmdlet.

If you provide no parameters, it will presume the Windows 10 ADK is on drive C: and that you’d like the custom WIM file to exist at C:\Pewim\custom.wim. Running this command will build the custom Windows PE WIM file with Windows PowerShell built in, and it will capture the resulting file and path into the $Wimfile object:

$Wimfile=New-WindowsPEWim

You can provide an alternate destination and temporary folder by using the WinPETemp and Destination parameters. The following example will use a temporary folder called C:\WinPEtemp and place the custom.wim file in the C:\CustomWim folder:

We need to identify the current location of the DeployImage module. To be honest, it could be in my GitHub folder, your personal modules folder, or almost anywhere. To do this, we’ll grab its location from the Path property when using Get-Module, and we’ll pipe this to Split-Path to get only the parent folder:

$Modulepath=Split-path ((get-module deployimage).path)

We can now create a folder to hold the module and copy it to our Windows PE key:

Believe it or not, that’s it! You should now be able to have a USB key that boots into Windows PowerShell 5.0, contains all the media and scripts to not only build a custom Nano Server WIM file, but also deploy it to a physical disk.

This module can be used easily to deploy any WIM file including Windows to Go.

This is by no means a final production. If you have feedback, comments, or critique, by all means pass it along to me. There is a lot that can be done to improve this module, including error checking, trapping, and additional Help.

Don’t miss next week when Dave Wyatt talks all about using Pester in Windows PowerShell.