Creazione di un VHD template per Windows 10

Nel post Automazione della creazione di VHD Template avevo discusso delle linee su come creare un VHD Template per Windows 8.1 sfruttando lo script PowerShell Convert-WindowsImage.ps1.

Tale script è stato aggiornato per supportare anche Windows 10 e Windpws Server 2016 è ed disponibile al seguente Convert-WindowsImage.ps1 — WIM2VHD for Windows 10 (also Windows 8 and 8.1).

Nella versione 10 (June 2015) lo script rende disponibile la funzione Convert-WindowsImage per consentirne l’utilizzo in modo semplice all’interno di altri script, a riguardo si veda ad esempio lo script per la creazione di un VHD/VHDS per l’implementazione di un Nano Server disponibile al seguente Create a New Nano Server VHD/VHDx.

Di seguito le novità introdotte in questa versione:

  • Works on (and with) Windows 10! (Also fully tested on Windows 8.1 with August 2014 and November 2014 updates).
  • The script is now a Function! You have to load it first (aka “dot-source”) and then call by its name, without extension.Please refer to the Examples section below for a code sample.
  • -Feature parameter now supports multiple input (array of strings).
  • -Edition parameter now supports multiple input (array of stings). Output will be multiple separate VHD(x)’es.
  • -Package. New parameter to inject Windows packages (e.g. updates or language packs) into the image.
  • -RassThru returns object(s) instead of a path.

    Fix. If the source is remote (UNC path), the script copies it locally into the user’s temp directory. Previously the local copy was not removed afterwards. Now we correctly delete it when no longer needed.
  • Fix. The function now works as expected with Powershell’s Strict Mode.
  • VHDX is the new default (Sorry Azure!). Use -VhdFormat to explicitly specify “VHD”.
  • GPT is the new default (Sorry Generation 1 virtual machines!). Use -VhdPartitionStyle to explicitly specify “MBR”.
  • UI is deprecated. This was a tough decition but I don’t have enough skills and time to maintain it and support with the new features I added over time. Probably the old -ShowUi option still works. But I cannot commit it to work with any of the new features or at all. Sorry about this folks. If anyone has suggestions and ready to help, please reach out to me and I will be happy to include your contributions.Works on (and with) Windows 10! (Also fully tested on Windows 8.1 with August 2014 and November 2014 updates).The script is now a Function! You have to load it first (aka “dot-source”) and then call by its name, without extension.Please refer to the Examples section below for a code sample.

Di seguito invece la procedura da seguire per la creazione di template VHD/VHX per Windows 10 utilizzando l’immagine iso per Windows 10 multiple editions a 64 bit in lingua italiana disponibili su MSDN (it_windows_10_multiple_editions_x64_dvd_6846987.iso) o l’iso della trial di Windows 10 Enterprise a 64 bit in lingua italiana (10240.16384.150709-1700.TH1_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_IT-IT.ISO) nell’ipotesi di avere copiato in una cartella C:\VHDTemplates lo script Convert-WindowsImage.ps1 e le iso necessarie it_windows_10_multiple_editions_x64_dvd_6846987.iso e 10240.16384.150709-1700.TH1_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_IT-IT.ISO.

Passo 1: Aprire PowerShell con privilegi amministrativi

Passo 2: Eseguire il cmdlet:

Set-ExecutionPolicy Unrestricted

Passo 3: Impostare la directory corrente:

Set-Location C:\VHDTemplates

Passo 4: Caricare le funzoni nello script:

. .\Convert-WindowsImage.ps1

Passo 5: Creare un Vhdx Template per Windows 10 Professional per una VM Gen2 (partizione GPT):

Convert-WindowsImage -SourcePath ‘.\it_windows_10_multiple_editions_x64_dvd_6846987.iso’ -VHDType Dynamic -VHDPartitionStyle GPT -SizeBytes 80GB -Edition ‘Windows 10 Pro’ -VHDFormat VHDX -VHDPath ‘.\W10-IT-x64-Pro.vhdx’

Passo 5: Creare un Vhdx Template per Windows 10 Enteprise Eval per una VM Gen2 (partizione GPT):

Convert-WindowsImage -SourcePath ‘.\10240.16384.150709-1700.TH1_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_IT-IT.ISO’ -VHDType Dynamic -VHDPartitionStyle GPT -SizeBytes 80GB -VHDFormat VHDX -VHDPath ‘.\W10-IT-x64-Ent-Eval.vhdx’

Passo 5: Creare un Vhd Template per Windows 10 Enteprise Eval per una VM Gen1 (partizione MBR):

Convert-WindowsImage -SourcePath ‘.\10240.16384.150709-1700.TH1_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_IT-IT.ISO’ -VHDType Dynamic -VHDPartitionStyle MBR -SizeBytes 80GB -VHDFormat VHD -VHDPath ‘.\W10-IT-x64-Ent-Eval.vhd’