Skip navigation
Customize Nano server deployment during creation

Customize Nano server deployment during creation

Q. I want to further customize my Nano server instance during its initial startup, what can I do?

A. The switches you pass during the New-NanoServerImage actually create an unattend.xml file in the VHD that is used during specialization to apply configurations. Once you have created the VHD you can mount the VHD and edit the unattend.xml prior to starting the VM. The PowerShell below will mount the VHD and open the unattend.xml file in notepad so you can edit. Then you can dismount the VHD.

$NanoVHDPath = "D:\VMs\NanoVM2\NanoServerVM.vhd"
$VHDMount = Mount-VHD -Path $NanoVHDPath -Passthru
$DriveLetter = $VHDMount | Get-Disk | Get-Partition | Get-Volume | Select-Object -ExpandProperty DriveLetter
$UnattendFile = $DriveLetter + ":\Windows\Panther\Unattend.xml"
notepad $UnattendFile #add <TimeZone>Central Standard Time</TimeZone> before </component> in oobeSystem
Dismount-VHD -Path $NanoVHDPath 

You could also automate the addition of XML into the unattend.xml file using PowerShell.

Below adds timezone to my Nano server VHD. You could modify this to work with any other changes you want. I have more detail on modifying XML with PowerShell that explains this example in more detail at http://windowsitpro.com/windows/add-elements-xml-using-powershell.

$NanoVHDPath = "D:\VMs\NanoVM2\NanoServerVM.vhd"
$VHDMount = Mount-VHD -Path $NanoVHDPath -Passthru
$DriveLetter = $VHDMount | Get-Disk | Get-Partition | Get-Volume | Select-Object -ExpandProperty DriveLetter
$UnattendFile = $DriveLetter + ":\Windows\Panther\Unattend.xml"

$xml = [xml](gc $UnattendFile)

$child = $xml.CreateElement("TimeZone", $xml.unattend.NamespaceURI)
$child.InnerXml = "Central Standard Time"
$null = $xml.unattend.settings.Where{($_.Pass -eq 'oobeSystem')}.component.appendchild($child) 

$xml.Save($UnattendFile)
Dismount-VHD -Path $NanoVHDPath 

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish