Jean-Yves Moschetto's blog

Tip and tricks on Microsoft products

NAVIGATION - SEARCH

Bulk Deploy Microsoft Windows Nano Server 2016 and join domain

      Hi,

As I searched the web how to automatically deploy NANO server and join it to Active Directory, I could only find incomplete solutions.
I saw many things with manual copy of the blob generated with djoin.exe ...
I went deep dive into "<DVD>:\NanoServer\NanoServerImageGenerator\NanoServerImageGenerator.psm1" and discovered everything is in the box.
For that I'm working with the last version of Windows 2016: Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_English_-3_MLF_X21-30350.ISO
 
You can manually create your own unattend.xml thanks to WAIK10, but no need for that; As I said, everything is in the module NanoServerImageGenerator.psm1
 
Also, as I am quite lazy and want the simplest code, this is what I wrote and which generates my disk.vhdx

 
<# 
 .NOTES
 ===========================================================================
  Created with:  SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.136
  Created on:    21/03/2017 08:11
  Created by:    Jean-Yves Moschetto jeanyves.moschetto@yoursystems.eu
  Organization:  CARIB INFRA - YOURSYSTEMS
  Filename:      
 ===========================================================================
 - Copy <Windows 2016 DVD\NanoServer> to C:\EXPLOIT\NanoServer
 - BasePath doesn't support network drive or UNC path
 - To be executed from a member Windows 10/2016 computer, as 'Domain admin' for account provisioning 
 - Must have a DHCP with DNS to join domain
#>

$Configurationdata = @{
 Global = @{ BasePath = 'C:\EXPLOIT\NanoServer'; MediaPath = 'D:\'; TargetPath = '\\10.10.10.2\c$\VM\VHD'; Domain = 'dom2016.local'; }
 Servers = @(
  @{ ComputerName = 'Nano1'; Edition = 'Datacenter'; DeploymentType = 'Guest' },
  @{ ComputerName = 'Nano2'; Edition = 'Standard'; DeploymentType = 'Guest' }
 )
}
Import-Module "$($Configurationdata.Global.BasePath)\NanoServerImageGenerator\NanoServerImageGenerator.psm1"
if ($Credential -eq $null) { $Credential = Get-Credential -Message 'Enter administrator password' -UserName Administrator }
ForEach ($Server in $Configurationdata.Servers)
{
 djoin.exe /provision /domain $($Configurationdata.Global.Domain) /machine $($Server.ComputerName) /savefile "$($Configurationdata.Global.BasePath)\$($Server.ComputerName).blob" /reuse
 New-NanoServerImage -DeploymentType $Server.DeploymentType `
      -Edition $Server.Edition `
      -MediaPath $Configurationdata.Global.MediaPath `
      -BasePath $Configurationdata.Global.BasePath `
      -TargetPath "$($Configurationdata.Global.TargetPath)\$($Server.ComputerName).vhdx" `
      -AdministratorPassword $Credential.Password `
      -DomainBlobPath "$($Configurationdata.Global.BasePath)\$($Server.ComputerName).blob" `
      -EnableRemoteManagementPort:$true
}
Just create your virtual machine manually or from script, attach the just created vhdx disk and boot.
It just takes 3 seconds to boot and here it is ... :
Logon into the domain, that's it :

Add comment