sábado, 22 de agosto de 2020

domingo, 2 de agosto de 2020

Sysprep (image creation)

 Here you are a guide for making windows images using sysprep. This can be useful if we have to set up several computers that share the same/similar configuration.


  • Install a virtual machine (drive type VHD) with the OS. We have to use a VM for getting an image clean of drivers. If we don’t have the last windows ISO we can download from here link.

  • Start Audit mode,  %windir%\system32\sysprep\sysprep.exe /audit /reboot (once the system restart we click cancel on next window.



  • Enable adminstrator account, configure the computer and install all software you need.

  • We can uninstall the  BLOATWARE in order to get a cleaner image(optional).

For getting the bloatware list we run next powershell command.

DISM /Online /Get-ProvisionedAppxPackages | select-string Packagename >> c:\Bloatware.txt



Once we have the list we need to made up two Powershell scripts, once for removing the provision of the apps and another one for uninstalling them. 


 The first one should have next structure:


 DISM /Online /Remove-ProvisionedAppxPackage /PackageName: (Package name)

 

And the second one this structure: 

Get-AppxPackage “(Package name)” | Remove-AppxPackage

 

Note: If posible we have to actívate script execution on Powershell using next command 


Set-ExecutionPolicy Unrestricted.


 Once the scripts have been run we have to roll back the script execution policy using next command. 


Set-ExecutionPolicy  Default


  • Once the computer is configured we have to getting it ready for creating the image. Copy the  “unatend.xml” file we want to use on following path: C:\Windows\Panther\   and reboot the computer using this command; Sysprep /generalize /shutdown /oobe.

This command runs  Sysprep and leave the computer ready for creating the image.




  • Now we have to mount the virtual drive using drive manager choosing Read-Only mode.



We pay attention to the  drive letter assigned and run following command.


 dism /capture-image /imagefile:c:\Install.wim /capturedir:( assigned letter):\ /name:"Windows 10 Pro" /Description:"Windows 10 Pro" /compress:maximum /checkintegrity /verify /bootable

 

Once the proccess has finished we split the “Install.wim” on order to be able of using FAT32 formar.


 Dism /Split-Image /ImageFile:Install.wim /SWMFile:install.swm /FileSize:3800

Now we mount the ISO we have used for installing the VM and copy everything on a folder (e.g. \myWindosImage) . This folder Will be use for creating the final installation media.


We replaced the original  “Install.wim” o “install.esd”, on folder “\myWindosImage \sources” for the files “Install.swm, Install2.swm…” we created previously and finally we copy everything on a USB stick with system file FAT32


Here you are the files I’ve used for this example.


Enjoy.


 Culex.