Customize Nano server deployment during creation

Customize your Nano server deployments with a simple bit of PowerShell.

John Savill

December 23, 2015

1 Min Read
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:VMsNanoVM2NanoServerVM.vhd"$VHDMount = Mount-VHD -Path $NanoVHDPath -Passthru$DriveLetter = $VHDMount | Get-Disk | Get-Partition | Get-Volume | Select-Object -ExpandProperty DriveLetter$UnattendFile = $DriveLetter + ":WindowsPantherUnattend.xml"notepad $UnattendFile #add Central Standard Time before  in oobeSystemDismount-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:VMsNanoVM2NanoServerVM.vhd"$VHDMount = Mount-VHD -Path $NanoVHDPath -Passthru$DriveLetter = $VHDMount | Get-Disk | Get-Partition | Get-Volume | Select-Object -ExpandProperty DriveLetter$UnattendFile = $DriveLetter + ":WindowsPantherUnattend.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 

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like