This Attune Blueprint creates a WinPE ISO file to install Windows OS on a specific device.
Builds Windows workstations and Windows Server machines with either BIOS or UEFI boot.
The process take the WinPE Essential files for the boot configuration being built and repackages the ISO file with the requries configuration files to automate the installation.
The steps in the Blueprint are performed on macOS or Linux.
A single WinPE ISO is created.
Contents
Create Windows autounattend WinPE ISO on macOS or Linux
Step 1 - Validate the Create Windows autounattend WinPE ISO Plan Parameters
Step 1.1 - Check if IP Address is in Subnet on macOS or Linux
Step 1.2 - Check if Gateway IP Address is in Subnet on macOS or Linux
Step 1.3 - Check Input Parameter kickstartedBootLoaderIsUefi for WinPE Kickstart on macOS or Linux
Step 1.4 - Check Windows and Boot Type Parameters for WinPE Kickstart on macOS or Linux
Step 1.5 - Check Maximum Length of Win10 Hostname on macOS or Linux
Step 1.6 - Check Input Parameter windowsFolderOnSamba for WinPE Kickstart on macOS or Linux
Step 1.7 - Confirm Plain WinPE ISO Exists on macOS or Linux
Step 2 - Copy and Rename WinPE BIOS ISO on macOS or Linux
Step 3 - Copy and Rename WinPE UEFI ISO on macOS or Linux
Step 4 - Extract WinPE ISO to Staging Folder on macOS or Linux
Step 5 - Deploy startnet.cmd on macOS or Linux
Step 6 - Deploy Windows Unattended Config on macOS or Linux
Step 7 - Deploy Post Setup PowerShell Script on macOS or Linux
Step 8 - Create post_install.wim Windows Image on macOS or Linux
Step 9 - Copy startnet.cmd to boot.wim on macOS or Linux
Step 10 - Copy autounattend.xml to boot.wim on macOS or Linux
Step 11 - Copy post_install.wim to boot.wim on macOS or Linux
Step 12 - Copy Drivers Drop in Folder to boot.wim on macOS or Linux
Step 13 - Change Ownership of winpe_staging Directory for Kickstart
Step 14 - Create BIOS Boot WinPE ISO from winpe_staging on macOS or Linux
Automate This
Use the Attune GUI for your Scripts
You've automated: Create Windows autounattend WinPE ISO on macOS or Linux
Get the most out of automation with our get started videos, product demonstrations, and more.
The following steps will guide you through the manual process.
echos to debug.ANDed with the netmask octet.ORed with the wildcard octet.Subnet Cheat Sheet - 24 Subnet Mask, 30, 26, 27, 29, and other IP Address CIDR Network References
Connect via ssh:
ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}
Execute the following script:
echo "IP address={newOsNode.ip}"
echo "subnet={newOsNodeSubnet.subnet}"
echo "netmask={newOsNodeSubnet.netmask}"
#echo "i, IP_OCTET, SUBNET_OCTET, NETMASK_OCTET, WILDCARD_MASK, OCTET_MIN, OCTET_MAX"
for i in $(seq 1 1 4)
do
IP_OCTET=$(echo "{newOsNode.ip}" | awk -F'.' "{print \$$i}")
SUBNET_OCTET=$(echo "{newOsNodeSubnet.subnet}" | awk -F'.' "{print \$$i}")
NETMASK_OCTET=$(echo "{newOsNodeSubnet.netmask}" | awk -F'.' "{print \$$i}")
OCTET_MIN=$((SUBNET_OCTET & NETMASK_OCTET))
WILDCARD_MASK=$((255 - NETMASK_OCTET))
OCTET_MAX=$((SUBNET_OCTET | WILDCARD_MASK))
#echo "$i. $IP_OCTET, $SUBNET_OCTET, $NETMASK_OCTET, $WILDCARD_MASK, $OCTET_MIN, $OCTET_MAX"
if [ "$IP_OCTET" -ge "$OCTET_MIN" ] &&
[ "$IP_OCTET" -le "$OCTET_MAX" ]
then
echo "Octet number $i, $OCTET_MIN <= $IP_OCTET <= $OCTET_MAX, ok."
else
echo "Octet number $i, $OCTET_MIN <= $IP_OCTET <= $OCTET_MAX is false. Not in range of the subnet mask."
false
fi
done
echos to debug.ANDed with the netmask octet.ORed with the wildcard octet.Subnet Cheat Sheet - 24 Subnet Mask, 30, 26, 27, 29, and other IP Address CIDR Network References
Execute the following script:
echo "gateway IP address={newOsNodeSubnet.gateway}"
echo "subnet={newOsNodeSubnet.subnet}"
echo "netmask={newOsNodeSubnet.netmask}"
#echo "i, GATEWAY_OCTET, SUBNET_OCTET, NETMASK_OCTET, WILDCARD_MASK, OCTET_MIN, OCTET_MAX"
for i in $(seq 1 1 4)
do
GATEWAY_OCTET=$(echo "{newOsNodeSubnet.gateway}" | awk -F'.' "{print \$$i}")
SUBNET_OCTET=$(echo "{newOsNodeSubnet.subnet}" | awk -F'.' "{print \$$i}")
NETMASK_OCTET=$(echo "{newOsNodeSubnet.netmask}" | awk -F'.' "{print \$$i}")
OCTET_MIN=$((SUBNET_OCTET & NETMASK_OCTET))
WILDCARD_MASK=$((255 - NETMASK_OCTET))
OCTET_MAX=$((SUBNET_OCTET | WILDCARD_MASK))
#echo "$i. $GATEWAY_OCTET, $SUBNET_OCTET, $NETMASK_OCTET, $WILDCARD_MASK, $OCTET_MIN, $OCTET_MAX"
if [ "$GATEWAY_OCTET" -ge "$OCTET_MIN" ] &&
[ "$GATEWAY_OCTET" -le "$OCTET_MAX" ]
then
echo "Octet number $i, $OCTET_MIN <= $GATEWAY_OCTET <= $OCTET_MAX, ok."
else
echo "Octet number $i, $OCTET_MIN <= $GATEWAY_OCTET <= $OCTET_MAX is false. Not in range of the subnet mask."
false
fi
done
If kickstartedBootLoaderIsUefi is set true, then checks if at least one of these are also true:
1. isWin10Uefi
2. isWinServerUefi
Execute the following script:
if {kickstartedBootLoaderIsUefi}
then
echo "isWin10Uefi = {isWin10Uefi}, isWinServerUefi = {isWinServerUefi}"
if ! {isWin10Uefi} &&
! {isWinServerUefi}
then
echo "If kickstartedBootLoaderIsUefi is set true, then
one of isWin10Uefi or isWinServerUefi must also be
set true" >&2
false
fi
fi
echo "SUCCESS: Ok"
Checks exactly if one of these are set true:
1. isWin10Bios
2. isWin10Uefi
3. isWinServerBios
4. isWinServerUefi
Execute the following script:
function printVals() {
echo "
isWin10Bios = {isWin10Bios}
isWin10Uefi = {isWin10Uefi}
isWinServerBios = {isWinServerBios}
isWinServerUefi = {isWinServerUefi}
"
}
echo "Checking ..."
printVals
COUNT=$(printVals | grep -c "true" || true)
echo "COUNT=${COUNT}"
if [ $COUNT -ne 1 ]
then
echo "FAIL: You must have exactly one only have one of the parameters above set to true" >&2
false
fi
echo "SUCCESS: The parameters above are set correctly"
Windows Desktop 10 has a hostname maximum length of 15 characters.
if one of these Attune parameters are true, this step checks for the hostname length and fails if it is larger than 15.
1. isWin10Bios
2. isWin10Uefi
Execute the following script:
if {isWin10Bios} || {isWin10Uefi}
then
HOSTNAME="{newOsNode.hostname}"
LENGTH="${#HOSTNAME}"
MAX_LENGTH="15"
if [ "${LENGTH}" -gt "${MAX_LENGTH}" ]
then
echo "Length of hostname ${LENGTH} for Win10 can't be more than 15."
false
else
echo "Length of hostname ${LENGTH} is less than or equal to 15."
fi
else
echo "Not Win10, skipping."
fi
isWinPEKickstart is set true.windowsFolderOnSamba is set to windows10, checks if one of these are set true
* isWin10Bios
* isWin10UefiwindowsFolderOnSamba is set to one of windows2016, windows2019 or windows2022 checks if one of these are set true:
* isWinServerBios
* isWinServerUefiExecute the following script:
if ! {isWinPEKickstart}
then
echo "Please set isWinPEKickstart as the string 'true'"
exit 1
fi
if [ {windowsFolderOnSamba} == "windows10" ]
then
if ! {isWin10Bios} && ! {isWin10Uefi}
then
echo "Please set one of 'isWin10Bios' or 'isWin10Uefi' to true to install Win10."
exit 1
fi
fi
if [ {windowsFolderOnSamba} == "windows2016" ] ||
[ {windowsFolderOnSamba} == "windows2019" ] ||
[ {windowsFolderOnSamba} == "windows2022" ]
then
if ! {isWinServerBios} && ! {isWinServerUefi}
then
echo "Please set one of 'isWinServerBios' or 'isWinServerUefi' to true to install Windows Server."
exit 1
fi
fi
Checks if the WinPE plain BIOS ISO {automationWorkerLinuxBaseDirectory}/winpe_plain_bios.iso exists.
If it does not, a message will be printed to ask the user to run the WinPE BIOS ISO creation blueprint Create Windows PE (WinPE) Plain ISO on macOS or Linux Worker.
Only applies to BIOS kickstarts so if any of these parameters are set the string true:
isWin10BiosisWinServerBiosExecute the following script:
if {isWin10Bios} || {isWinServerBios}
then
DIRECTORY="{automationWorkerLinuxBaseDirectory}"
cd "${DIRECTORY}"
ISO="winpe_plain_bios.iso"
if [[ -f ${ISO} ]]
then
echo "${DIRECTORY}/${ISO} exists. Great."
else
echo "${DIRECTORY}/${ISO} does not exist. Please run blueprint \"Create Windows PE (WinPE) Plain ISO on macOS or Linux Worker\" to create it."
exit 1
fi
elif {isWin10Uefi} || {isWinServerUefi}
then
DIRECTORY="{automationWorkerLinuxBaseDirectory}"
cd "${DIRECTORY}"
ISO="winpe_plain_uefi.iso"
if [[ -f ${ISO} ]]
then
echo "${DIRECTORY}/${ISO} exists. Great."
else
echo "${DIRECTORY}/${ISO} does not exist. Please run blueprint \"Create Windows PE (WinPE) Plain ISO on macOS or Linux Worker\" to create it."
exit 1
fi
else
echo "Parameter configuration error"
exit 1
fi
Makes a copy of the winpe_plain_bios.iso as winpe.iso in the folder {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn.
This ISO is BIOS bootable and works for:
Only applies to BIOS kickstarts so if any of these parameters are set the string 'true':
isWin10BiosisWinServerBiosExecute the following script:
if {isWin10Bios} || {isWinServerBios}
then
FOLDER="{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
mkdir --parents "${FOLDER}"
cd "${FOLDER}"
cp --verbose "../winpe_plain_bios.iso" "winpe.iso"
else
echo "Skipping for UEFI ISO creation."
fi
Makes a copy of the winpe_plain_uefi.iso as winpe.iso in the folder {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn.
This ISO is UEFI bootable and works for:
Only applies to UEFI kickstarts so if any of these parameters are set the string 'true':
Execute the following script:
if {isWin10Uefi} || {isWinServerUefi}
then
FOLDER="{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
mkdir -p "${FOLDER}"
cd "${FOLDER}"
cp -v "../winpe_plain_uefi.iso" "winpe.iso"
else
echo "Skipping for BIOS ISO creation."
fi
Extract winpe.iso to a winpe_staging folder.
Execute the following script:
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
FOLDER=winpe_staging
mkdir -p "${FOLDER}"
7z x winpe.iso -o"${FOLDER}"
Deploys startnet.cmd.
This script is run by WinPE.
The startnet.cmd is run by WinPE. This script: 1. Installs drivers from "attune_drivers". 2. Sets the IP address. 3. Mounts the Samba server that hosts the extracted Windows ISOs as the "Z" drive. 4. Runs Windows setup.exe.
The Mako parameter "windowsFolderOnSamba" can have these values:
Copy the File(s) WinPE_startnetcmd.tar to the target node.
{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}, relative to the home directory
Deploys the generic autounattend.xml.
Set one of these true depending on whether you want Windows Desktop 10 or Windows Server for BIOS or UEFI boot methods.
isWin10BiosisWin10UefiisWinServerBiosisWinServerUefiSet isWinPEKickstart to true for WinPE kickstarts.
For these Windows versions: * WIndows Desktop 10 * WIndows Server 2016 * WIndows Server 2019 * WIndows Server 2022
For these boot methods: * BIOS * UEFI
Copy the File(s) Windows_Unattended_config.tar to the target node.
{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}, relative to the home directory
Deploys the post install setup PowerShell script post_install_setup.ps1 to {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}.
This file is called by the "
This script is run once post installation of the WIndows operating system.
Copy the File(s) Post_Install_Setup_PowerShell_Script.tar to the target node.
{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}/post_install_wim, relative to the home directory
Creates a post_install.wim file from the contents of post_install_wim on Creates a post_install.wim file from the contents of post_install_wim on macOS or Linux Worker.
Execute the following script:
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
SOURCE="post_install_wim"
WIMFILE="post_install.wim"
echo "Creating ${WIMFILE} from directory ${SOURCE}."
wimcapture "${SOURCE}" "${WIMFILE}" --check
Moves startnet.cmd to the folder /Windows/System32.
Execute the following script:
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
wimupdate winpe_staging/SOURCES/BOOT.WIM \
--command="add startnet.cmd /Windows/System32/startnet.cmd"
Copy the autounattend.xml file to the root of boot.wim.
Execute the following script:
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
wimupdate winpe_staging/SOURCES/BOOT.WIM \
--command="add autounattend.xml /autounattend.xml"
Copy post_install.wim file to the root of boot.wim.
Execute the following script:
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
wimupdate winpe_staging/SOURCES/BOOT.WIM \
--command="add post_install.wim /post_install.wim"
Copy drivers from the drop in directorty into /drivers directory in boot.wim.
Execute the following script:
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
DRIVERS_DROP_IN_FOLDER="{automationWorkerLinuxBaseDirectory}/drivers-{newOsNode.fqn}"
if [ -d "${DRIVERS_DROP_IN_FOLDER}" ]
then
wimupdate winpe_staging/SOURCES/BOOT.WIM \
--command="add ${DRIVERS_DROP_IN_FOLDER} /drivers"
else
echo "Drivers drop in folder ${DRIVERS_DROP_IN_FOLDER} does not exist. No drivers copied."
fi
Connect via ssh:
ssh {automationworkerlinuxuserroot}@{automationworkerlinuxnode}
Execute the following script:
if {kickstartedBootLoaderIsUefi}
then
cd "{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
USER="{automationWorkerLinuxUser.user}"
GROUP="$(id -gn {automationWorkerLinuxUser.user})"
echo "User: $USER, Group: $GROUP"
chown -R -v "$USER:$GROUP" "winpe_staging"
else
echo "Skipping for BIOS boot."
fi
Creates a BIOS bootable ISO at {automationWorkerLinuxBaseDirectory}/kickstart_{newOsNode.fqn}.iso from the WinPE staging directory {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}/winpe_staging.
Only applies to BIOS kickstarts so if any of these parameters are set the string true:
isWin10BiosisWinServerBiosConnect via ssh:
ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}
Execute the following script:
cd "{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
if {isWin10Bios} || {isWinServerBios}
then
ISO_NAME="kickstart_{newOsNode.fqn}.iso"
if uname | \
grep -iq "darwin"
then
echo "is macOS"
export PATH="${HOME}/Parallels/homebrew/bin:$PATH"
echo "Using $(which xorriso)"
xorriso -as mkisofs \
-b boot.img \
-no-emul-boot \
-c BOOT.CAT \
-iso-level 3 \
-joliet-long \
-relaxed-filenames \
-J \
-full-iso9660-filenames \
-disable-deep-relocation \
-omit-version-number \
-V "KS_WIN" \
-o "{automationWorkerLinuxBaseDirectory}/${ISO_NAME}" \
winpe_staging
else
echo "not macOS"
mkisofs \
-b boot.img \
-no-emul-boot \
-c BOOT.CAT \
-iso-level 3 \
-udf \
-joliet-long \
-relaxed-filenames \
-allow-limited-size \
-J \
-full-iso9660-filenames \
-disable-deep-relocation \
-omit-version-number \
-V "KS_WIN" \
-o "{automationWorkerLinuxBaseDirectory}/${ISO_NAME}" \
winpe_staging
fi
else
echo "Skipping for UEFI ISO creation."
fi
mkwinpeimg cannot build a bootable UEFI system natively, but
the necessary UEFI boot files are included in the Windows
installation media.
Create a single partition of type EFI System, and format the partition to FAT32.
Execute the following script:
if {kickstartedBootLoaderIsUefi}
then
cd "{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
ISO="{automationWorkerLinuxBaseDirectory}/kickstart_{newOsNode.fqn}.iso"
[ -f "${ISO}" ] && rm "${ISO}"
if [[ "Darwin" == "$(uname)" ]]
then
hdiutil create -ov -srcfolder winpe_staging -fs "MS-DOS FAT32" \
-volname "KS_WIN" "${ISO}"
hdiutil makehybrid -iso -joliet -o ${ISO} ${ISO}.dmg
rm -rf ${ISO}.dmg
file ${ISO}
ls -ltrh ${ISO}
elif [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]] || [[ -f /etc/debian_version ]]
then
block=$(du --summarize winpe_staging | awk '{print $1}')
((block=block+10000))
echo "block size: ${block}"
mkfs.msdos -v -C "${ISO}" "${block}"
else
echo "Unsupported operating system."
exit 1
fi
else
echo "Skipping for BIOS boot."
fi
Connect via ssh:
ssh {automationworkerlinuxuserroot}@{automationworkerlinuxnode}
Execute the following script:
if {kickstartedBootLoaderIsUefi}
then
cd "{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
if [[ "Darwin" == "$(uname)" ]]
then
echo "is macOS, skipping"
elif [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]] || [[ -f /etc/debian_version ]]
then
MOUNT_FOLDER="uefi_mount"
MOUNT_PATH="{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}/${MOUNT_FOLDER}"
mkdir --parents --verbose ${MOUNT_FOLDER}
mount --verbose \
"../kickstart_{newOsNode.fqn}.iso" ${MOUNT_FOLDER}
cp -r --verbose winpe_staging/* "${MOUNT_FOLDER}"
if df -h | grep --ignore-case --quiet "${MOUNT_PATH}"
then
umount --verbose "${MOUNT_FOLDER}"
else
echo "${MOUNT_PATH} is not mounted. Skipping."
fi
else
echo "Unsupported operating system."
exit 1
fi
else
echo "Skipping for BIOS boot."
fi
You have completed this instruction.
Join our Discord channel and connect with like-minded individuals who share your passion. Engage in lively discussions, gain valuable insights, and stay updated on the latest trends in our industry. Don't miss out on this opportunity to network, learn, and grow together.
Click the link below and become a part of our vibrant community on Discord today!