Deploying images assigned to target machines

Scenario

An administrator needs to deploy a different master image to each target machine.

Solution

The administrator puts the images in a shared location that can be accessed from each target machine.

The administrator renames each image according to the target machine’s MAC address. The image destined to the machine with MAC address 01-02-03-04-05-06 will have the name, for example, image-01-02-03-04-05-06.tib.

The administrator writes a deployment script that can read the target machine’s MAC address and pull an image with a name corresponding to the MAC address from the shared location. The script can be executed on any number of target machines.

Sample script

setlocal
SET IMG_PATH=\\image_server\images
SET TMP_DRV_LETTER=h:
net use %TMP_DRV_LETTER% %IMG_PATH%
echo off
for /f "tokens=1-13 delims= " %%a in ('ipconfig /all') do (
IF %%a EQU Physical (
for /f "tokens=1-3 delims= " %%a in ('echo %%l') do (
IF EXIST %TMP_DRV_LETTER%\%%a.tib (
echo DEPLOYMENT IMAGE file: %%a.tib
asdcmd.exe /deploy /filename:%TMP_DRV_LETTER%\%%a.tib /harddisk:1 /target_partition:c
goto end
) ELSE (
echo THE IMAGE FILE %IMG_PATH%\%%a.tib NOT FOUND
)
)
)
)
:end
echo on
net use %TMP_DRV_LETTER% /d
wpeutil Reboot
endlocal

What this script does:

  1. Mounts the network folder containing the set of images (one image corresponds to one target machine)
  2. Retrieves the MAC address of the target machine
  3. Generates a .tib file name (if MAC address is 01-02-03-04-05-06 then the .tib file name must be 01-02-03-04-05-06.tib)
  4. Searches the network folder for an image with such name
  5. Deploys the image if found
  6. Restarts or shuts down the target machine

Environment variables: