Archive for March, 2016

Making NanoServerImageGenerator.psm1 more useful on a daily basis

I’ve been playing around with Nano Server these couple of days, but grew a bit tired of needing to import the NanoServerImageGenerator.psm1 Windows PowerShell Module at the beginning of every Windows PowerShell session.

Now, you might say I’m a bit too tidy, because I properly close any session I don’t need for the next two minutes. Additionally, the fact that Windows PowerShell Cmdlets from the built-in Windows PowerShell Modules automatically load, doesn’t help me in using the Windows PowerShell Cmdlets from the NanoServerImageGenerator.psm1 Windows PowerShell Module. Yes, I’m that spoiled. 😉

So, I decided to copy the PowerShell Module to the PowerShell Modules folder to get access to its function without even importing  it on the session, effectively adding it to the collection of built-in Windows PowerShell Modules. Using your Windows Server 2016 Installation Media, copy it with these three example PowerShell one-liners in an elevated PowerShell window:

New-Item “C:\Program Files\WindowsPowerShell\Modules\NanoServerImageGenerator” -Type Directory

Copy-Item “X:\NanoServer\NanoServerImageGenerator.psm1″ -Destination “C:\Program Files\WindowsPowerShell\Modules\NanoServerImageGenerator\NanoServerImageGenerator.psm1” -Force

New-ModuleManifest -Path  “C:\Program Files\WindowsPowerShell\Modules\NanoServerImageGenerator\NanoServerImageGenerator.psd1” -RootModule NanoServerImageGenerator.psm1

Now, on this system, I can build the Nano Server images I’d want, without running into the otherwise inevitable is not recognized as the name of a cmdlet, function, script file, or operable program errors for the Windows PowerShell Cmdlets in the NanoServerImageGenerator Windows PowerShell Module.

Available Windows PowerShell Cmdlets in NanoServerImageGenerator.psm1 in Windows Server 2016 Technical Preview 4

I’ve been playing around with Nano Server these couple of days and have been extensively using the NanoServerImageGenerator Windows PowerShell Module that shipped with the Installation Media for Windows Server 2016 Technical Preview 4 as the file NanoServerImageGenerator .psm1 file in the NanoServer folder.

You might be wondering which Windows PowerShell Cmdlets are available through this Windows PowerShell Module, so here is the list:

  1. Edit-NanoServerImage
  2. Get-NanoServerPackages
  3. New-NanoServerImage

 

Edit-NanoServerImage

The Edit-NanoServerImage Windows PowerShell Cmdlet can be used to modify a base Nano Server installation image adding packages, drivers  and configuring operating system options.

This cmdlet expects that you ran New-NanoServerImage in advance.
It operates on the image produced by New-NanoServerImage as requested.

Possible operations are: Add packages, add drivers, set computer name, set administrator password, join a domain, enable debug, enable EMS and set static IP address.

 

Get-NanoServerPackages

The Get-NanoServerPackages Windows PowerShell Cmdlet can be used to retrieve the list of available packages from the Windows Server 2016 Technical Preview 4 installation media.

This cmdlet scans the given media and returns a list of packages available to be embedded into the Nano Server image.

 

New-NanoServerImage

The New-NanoServerImage Windows PowerShell Cmdlet can be used to create a base Nano Server installation image.

This cmdlet makes a local copy of the necessary files from the installation media and converts the included WIM Nano Server image into a VHD(X) image. It then makes a copy of the converted VHD(X) image into a user-supplied path. After that, the following operations can be applied:

  • Add packages
  • Add drivers
  • Set computer name
  • Set administrator password
  • Join a domain
  • Enable debug
  • Enable EMS
  • Set static IP address