Update: Windows 10 Best Practices using ZCM - Moving to WinPE

3 Likes
over 1 year ago

Introduction

3 years ago I have published our Micro Focus Professional Services “Windows 10 Best Practices using ZENworks Configuration Management”: /collaboration/zenworks/w/zenworkstips/14350/windows-10-best-practices-using-zcm

Most topics in this document are still valid and many customers and partners are using these guidelines, but many of them asked for guidelines how to move to WinPE based Imaging to deploy Windows 10.

This article describes all pre-requisites, requirements and all steps to integrate a customized WinPE environment into your ZCM environment and how to use existing images with WinPE.

A basic knowledge of ZCM and Windows 10 Deployment is required.

As the space here is very limited, you can download the full document for more details.

Here is a short summary of the content.

Prepare your Environment

Update your Zone

Update your ZCM zone to at least ZCM 2017 Update 4 to have full support for ZCM imaging and WinPE. It´s recommended to update to ZCM 2020. Refer to online documentation how to do this.

Prepare a Windows 10 Administrator workstation

  • Update your Zone
  • Download and Install  ADK for Windows 10 1903 (or higher) including WinPE Addons (now available as a separate download)
  • Install ZCC-Helper

Customizing WinPE

Microsoft delivers only WinPE files with limited functionality. Therefore it´s required to add some useful features to support scripting methods or other functionality.

Please refer to: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-add-packages--optional-components-reference

We discussed possible options internally and with several customers and partners and agreed to support Powershell as preferred scripting language. Based on this we need to add the following components to WinPE:

  • WinPE-NetFx.cab
  • WinPE-PowerShell.cab
  • WinPE-WMI.cab
  • WinPE-Scripting.cab

Adding Packages to WinPE

Adding additional features can be done with DISM or you can use the small tool “WIMProcessor” found in “C:\Users\<your user>\AppData\Roaming\Novell\ZENworks\ZCCHelper\bin”

For example:

WIMProcessor.exe addPackage <path to winpe.wim>  <path to OC cab file>

A detailed description of all required steps you can find in the documents attached to this article.

Create your new Windows 10 base image(s) using WinPE

When you currently use our Best Practices you may have one Windows 10 base image and you may have several addon-images for Syprep-Files, drivers and ZCM-Agent.

In this case you are just a few minutes away from your WinPE-base imaging process. As all addon-images are compatible with WinPE there is no need to touch them.

To work with WinPE it´s only required to convert your existing Windows 10 (zmg) base images into Win-Pe-based images.

Creating a WinPE script with Powershell

As already explained our recommended scripting language is Powershell as it has a similar flexibility as bash scripting. It´s recommended either to use Powershell ISE or an editor that supports scripting languages like Notepad . With such editors the script is easier to read. So open your preferred editor and start with a new script i.e.: IMAGING-SCRIPT-WINPE.PS1

Here are a few examples of script blocks/functions I use in my script. A full script can be found in the appendix.

Declaring variables

In most cases it´s useful to declare some customer specific variables.

Customerinfo

#CUSTOMERINFO

$CUSTOMERNAME="MICROFOCUS"

$SOLUTIONNAME="WIN10 Installation - WINPE"

$IMAGEPATH="WINDOWS10"

$WIN10BASE="WIN10-BASE1909-PE"

$WIN10BOOTUEFI="WIN10-BOOT1909-PE"

$WIN10BOOTMBR="WIN10-BOOT1909-PE-MBR"

 

 

Disk Partitioning

Disk partitioning can be done as follows:

UEFI

BIOS

FUNCTION CREATE_PARTITIONS_UEFI

{

img -pd -all

img -pc 1 -type=NTFS -size=450 -guid=WRE

img -pc 2 -type=FAT32 -size=100 -guid=ESP

img -pc 3 -type=RAW -size=128 -guid=MRP

img -pc 4 -type=NTFS -guid=MBD

img -pa1

img -pa2

img -pa3

}

FUNCTION CREATE_PARTITIONS_BIOS

{

img -pd -all

img -pc 1 -type=NTFS -size=512 -guid=WRE

img -pc 2 -type=NTFS -guid=MBD

img -pa1

img -pa2

}

 

This will delete all existing partitions and setup required partitions for an UEFI/BIOS device. Please do not use diskpart to delete ALL partitions as this will delete the image safe data (ZISD).

Get workstation environment

With WinPE you can still use ziswin to get some workstation information. In addition you can use WMI functions.

GET ENVIRONMENT FROM zisview -s

FUNCTION GET_ZISD_ENV {

        Param (

        [String]

        $ZISViewOption

        )

                             

               if ( -not ( Test-Path "${env:SystemRoot}\System32\zisview.txt") ){

                if ( Test-Path "${env:SystemRoot}\System32\zisview.exe" ){

                    zisview -s >"${env:SystemRoot}\System32\zisview.txt"

                } else {

                    write-host "[${Date}][FATAL] command '${env:SystemRoot}\System32\zisview.exe' not found"

                }

            }

            if ( Test-Path "${env:SystemRoot}\System32\zisview.txt"){

                                                           $ZISViewOptionOut = get-content ${env:SystemRoot}\System32\zisview.txt | ForEach-Object {$_|select-string $ZISViewOption}

                                                           $ZISViewOptionOut = $ZISViewOptionOut -Split("=")

                                                           $ZISViewOptionOut = $ZISViewOptionOut[1] -replace ("""","")

                Return $ZISViewOptionOut      

                             }

                        

                                           

}

 

Using this function you can directly access the following device parameters: i.e. declaring some variables

$global:SMBIOS_MANUFACTURER=GET_ZISD_ENV SMBIOS_MANUFACTURER

$global:SMBIOS_PRODUCT=GET_ZISD_ENV SMBIOS_PRODUCT

$global:SMBIOS_MAC=GET_ZISD_ENV SMBIOS_MAC

$global:SMBIOS_BIOS_SERIAL=GET_ZISD_ENV SMBIOS_BIOS_SERIAL

$global:SMBIOS_BIOS_ASSET_TAG=GET_ZISD_ENV SMBIOS_BIOS_ASSET_TAG

This can be used in a function:

WORKSTATION INFO

FUNCTION WORKSTATION_INFO

{

    $global:COMPUTERNAME=zisview computername

    $global:COMPUTERINFO=Get-ComputerInfo -Property BIOS*

    $global:IMG_BOOT_MODE=$COMPUTERINFO.BiosFirmwareType

    $global:SMBIOS_MANUFACTURER=GET_ZISD_ENV SMBIOS_MANUFACTURER

    $global:SMBIOS_PRODUCT=GET_ZISD_ENV SMBIOS_PRODUCT

    $global:SMBIOS_MAC=GET_ZISD_ENV SMBIOS_MAC

    $global:SMBIOS_BIOS_SERIAL=GET_ZISD_ENV SMBIOS_BIOS_SERIAL

    $global:SMBIOS_BIOS_ASSET_TAG=GET_ZISD_ENV SMBIOS_BIOS_ASSET_TAG

}

 

Setting the name of the workstation

Many customers are using serial number or asset tag as device name or a custom naming convention. So you use need to put the correct name into the ZISD and the ZCM agent will change the windows hostname accordingly.

Setting the hostname

FUNCTION WRITE_ZIS

{

  #Writing Windows NetBios Name and DNSHostname to ZIS record

  zisedit ComputerName="$WSNAME"

  zisedit DNSHostname="$WSNAME"

}

 

  • $WSNAME=$SMBIOS_BIOS_SERIAL or
  • $WSNAME=$SMBIOS_BIOS_ASSET_TAG

If you want to use a custom hostname, you can ask for the hostname if not already set.

Getting Hostname

FUNCTION GET_WSNAME

{

$WSNAME=zisview computername

 

IF ($WSNAME -eq $NULL) {

 

write-host "--------------------------------------------"   

write-host "--------------------------------------------"   

write-host "--------------------------------------------"   

write-host "           $CUSTOMERNAME                    "

write-host "$SOLUTIONNAME                               "

write-host "--------------------------------------------"   

write-host "--------------------------------------------"   

write-host "--------------------------------------------"      

write-host "         Please enter PC-NAME          "

write-host "            (max. 15 digits )              "

$wsname = read-host -Prompt "Enter computername"

if ( $wsname.Length -gt 15 ) { $wsname=$wsname.Substring(0,15) }

write-host "      Die Eingabe war: $WSNAME              "

write-host "--------------------------------------------"   

write-host "--------------------------------------------"        

WRITE_ZIS

}

}

 

Detect Hardware

As the scripted image solution can be used for every hardware type, you need to select the correct hardware image based on hardware specific information i.e. the productname or similar.

Detect Hardware

FUNCTION GET_HWINFO

{

 

############## VMWARE ##############

if ( "$SMBIOS_PRODUCT" -match "VMware*") {

 

$global:HARDWARE_IMAGE="VMWARE15"

$global:HW_TYPE="DESKTOP"

write-host "Hardwareimage:$HARDWARE_IMAGE"

}

 

############## Lenovo T490s ##############

if ( "$SMBIOS_PRODUCT" -like "20N*") {

 

$global:HARDWARE_IMAGE="LENOVOT490S"

$global:HW_TYPE="NOTEBOOK"

write-host "Hardwareimage:$HARDWARE_IMAGE"

}

 

############## Surface Pro 7 ##############

if ( "$SMBIOS_PRODUCT" -match "Surface Pro 7") {

 

$global:HARDWARE_IMAGE="SURFACEPRO7"

$global:HW_TYPE="NOTEBOOK"

write-host "Hardwareimage:$HARDWARE_IMAGE"

}

 

 

Now you have set partition configuration, computername and hardware information. Now you are ready to restore your images.

Restoring Images

Depending on your configuration you need to restore your images.

Restoring Images (UEFI)

FUNCTION RESTORE_IMAGES_UEFI

{

#Restore Images

$IMAGESERVER=$PROXYADDR

write-host "Restoring Windows Base Partitions ($WIN10BOOTUEFI)...."

img -rp $IMAGEPATH/$WIN10BOOTUEFI.zmg -ip=$IMAGESERVER -ap=a1:p1

write-host "Restoring Windows Base Partitions ($WIN10BOOTUEFI)...."

img -rp $IMAGEPATH/$WIN10BOOTUEFI.zmg -ip=$IMAGESERVER -ap=a2:p2

write-host "Restoring Windows Base Partitions ($WIN10BASE)...."

img -rp $IMAGEPATH/$WIN10BASE.zmg -ip=$IMAGESERVER -ap=a4:p4

write-host "Restoring Addon-Images...."

write-host "Restoring Sysprep...."

img -rp $IMAGEPATH/WIN10-SYSPREP.zmg -ip=$IMAGESERVER -ap=a4:p4

write-host "Restoring NCSTools...."

img -rp $IMAGEPATH/WIN10-NCSTOOLS.zmg -ip=$IMAGESERVER -ap=a4:p4

write-host "Restoring Hardware-Images...."

img -rp $IMAGEPATH/WIN10-${HARDWARE_IMAGE}.zmg -ip=$IMAGESERVER -ap=a4:p4

write-host "Restoring ZEN Agent...."

img -rp $IMAGEPATH/WIN10-ZCM-AGENT.zmg -ip=$IMAGESERVER -ap=a4:p4

 

Please check your existing addon-images to reflect the correct “-ap” parameter. In this case all addon-images contain a partition 4 with all files.

If you have devices with bios configuration you can use the same base images and addon-images, but you need to adjust some parameters.

Restoring Images (BIOS)

FUNCTION RESTORE_IMAGES_BIOS

{

Restore Images

$IMAGESERVER=$PROXYADDR

write-host "Restoring Windows Base Partitions ($WIN10BASE)...."

img -rp $IMAGEPATH/$WIN10BOOTMBR.zmg -ip=$IMAGESERVER -ap=a1:p1

img -rp $IMAGEPATH/$WIN10BASE.zmg -ip=$IMAGESERVER -ap=a4:p2

write-host "Restoring Addon-Images...."

write-host "Restoring Sysprep...."

img -rp $IMAGEPATH/WIN10-SYSPREP.zmg -ip=$IMAGESERVER -ap=a4:p2

write-host "Restoring NCSTools...."

img -rp $IMAGEPATH/WIN10-NCSTOOLS.zmg -ip=$IMAGESERVER -ap=a4:p2

write-host "Restoring Hardware-Images...."

img -rp $IMAGEPATH/WIN10-${HARDWARE_IMAGE}.zmg -ip=$IMAGESERVER -ap=a4:p2

write-host "Restoring ZEN Agent...."

img -rp $IMAGEPATH/WIN10-ZCM-AGENT.zmg -ip=$IMAGESERVER -ap=a4:p2

}

 

 

At the end you need a function to distinguish between UEFI and BIOS

Restoring Images based on Boot Mode

SWITCH ($IMG_BOOT_MODE){

 

               UEFI {

 

                              CREATE_PARTITIONS_UEFI

                              RESTORE_IMAGES_UEFI

                              }

               BIOS {

                              CREATE_PARTITIONS_BIOS

                              RESTORE_IMAGES_BIOS

                              }

               }

 

When you are ready with your script, you must create an imaging bundle.

Creating Imaging Bundles

  • Start your ZCC and create a new preboot bundle.
  • Select WinPE Imaging Script from the menu or select empty bundle. This is only default category. You can add all other types afterwards.
  • Enter a name based on your naming conventions: WINPE-WIN10-ALL
  • Now select “Powershell Script” and enter or copy your script into the scriptbox. Please make sure your script does not exceed 32000 characters.

Creating a hardware rule

Start ZCC and goto Configuration/Device Management/Preboot Services.

Goto Device Imaging Work Assignment/Hardware Rules and create a new Rule.

Point your rule to the newly created imaging bundle a select a filter. The filter can be very simple as the hardware detection inside the script will detect the correct images or you can select specific hardware to use this new script. In this case all other types can still use linux based imaging.

Ready to deploy Windows 10 using WinPE

Now you are ready to use your WinPE-based imaging solution! Please make sure to download the attached file which includes a batch file to automated the creation of a custom WinPE and a powershell script that can be used to setup Windows 10 with WinPE.

Have fun!

 

Labels:

How To-Best Practice
Configuration Management
Comment List
Anonymous
Related Discussions
Recommended