How to Create Windows Server 2016 (Win2016) autounattend Dual ISO on macOS or Linux Worker

This documentation is generated by Attune

Automate This

Use the Attune GUI for your Scripts

    1 Download Attune
    2 Copy the Attune Project URL
    3 Clone the Project in Attune
    4 Plan your Job(s)
    5 Run your Job(s)

You've automated: Create Windows Server 2016 (Win2016) autounattend Dual ISO on macOS or Linux Worker


Get the most out of automation with our get started videos, product demonstrations, and more.

Learn Attune Automation

The following steps will guide you through the manual process.

To Debug
  • Uncomment out the echos to debug.
Logic
  • For loop loops through each octet in the IP address, subnet range octet and subnet mask.
  • For each octet:
    • The min octet is the subnet octet bitwised ANDed with the netmask octet.
    • A wildcard octet is 255 - netmask octet.
    • The max octet is the subnet octet bitwised ORed with the wildcard octet.
    • The IP address octet is tested to see if it is between the min and max octets.
References

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
                
            

To Debug
  • Uncomment out the echos to debug.
Logic
  • For loop loops through each octet in the gateway IP address, subnet range octet and subnet mask.
  • For each octet:
    • The min octet is the subnet octet bitwised ANDed with the netmask octet.
    • A wildcard octet is 255 - netmask octet.
    • The max octet is the subnet octet bitwised ORed with the wildcard octet.
    • The gateway IP address octet is tested to see if it is between the min and max octets.
References

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
                
            

Checks if at least one of isWinServerBios or isWinServerUefi is set tot true.

Execute the following script:

                
if ! {isWinServerBios} && ! {isWinServerUefi}
then
    echo "Please set one of 'isWinServerBios' or 'isWinServerUefi' to true to install Windows Server 2016, 2019 or 2022."
    exit 1
else
    echo "Ok."
fi
                
            

Deletes the build files and kickstart ISO.

Execute the following script:

                
DIR="{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
[[ -d ${DIR} ]] && rm -rf ${DIR} && echo "Removed ${DIR}" || \
    echo "No directory to remove."

ISO={automationWorkerLinuxBaseDirectory}/*{newOsNode.fqn}.iso
[[ -f ${ISO} ]] && rm -fv ${ISO} || echo "No ISO to remove."
                
            

Deploys Windows Server 2016 ISO to {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}.

Download from https://www.microsoft.com/en-us/evalcenter/download-windows-server-2016.

Copy the File(s) Win2016_ISO.tar to the target node.

Deploy the File(s) here:

{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}, relative to the home directory

Extracts the boot.img from the ISO. This is required for passing to mkisofs to regenerate a bootable BIOS ISO.

Only applies to BIOS kickstarts so if any of these parameters are set the string true:

  1. isWin10Bios
  2. isWinServerBios

Execute the following script:

                
if {isWin10Bios} || {isWinServerBios}
then

    # Extract the boot.img out of the WinPE ISO
    
    cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
    
    # Case insensitve globbing
    shopt -s nocaseglob
    
    # Set the filename of the ISO
    F=$(ls *.iso)
    
    # Get the Boot image offset
    OFFSET=`isoinfo -d -i $F | grep Bootoff | cut  -c21-`
    
    # Extract the boot.img.
    dd if=$F of=boot.img bs=2048 count=8 skip=$OFFSET
    
else
    echo "Skipping for UEFI ISO creation."
fi
                
            

Extracts the Windows ISO.

Execute the following script:

                
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}

# Case insensitve globbing
shopt -s nocaseglob

if ls | grep -q *iso
then
    
    ISO="$(echo *iso)"
    echo "ISO is $ISO"
    
    7z x "${ISO}"
    
    rm -v "${ISO}"
else
    echo "ISO is already extracted."
fi
                
            

From https://serverfault.com/questions/353826/windows-boot-iso-file-without-press-any-key this disables the "Press any key To boot from CD or DVD . . . .".

Execute the following script:

                
if {isWin10Uefi} || {isWinServerUefi}
then

    cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}
    cd efi/microsoft/boot/
    
    cp --verbose efisys_noprompt.bin efisys.bin
else
    echo "Skipping for BIOS ISO creation."
fi
                
            

Creates a BIOS bootable Windows ISO called kickstart_{newOsNode.fqn}.iso from the contents in folder {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}.

Only applies BIOS kickstarts so if any of these parameters are set the string true'`:

  1. isWin10Bios
  2. isWinServerBios

Execute the following script:

                
cd "{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"

if {isWin10Bios} || {isWinServerBios} 
then
    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 \
            -udf \
            -joliet-long \
            -relaxed-filenames \
            -J \
            -full-iso9660-filenames \
            -disable-deep-relocation \
            -omit-version-number \
            -V "KS_WIN" \
            -o {automationWorkerLinuxBaseDirectory}/kickstart_{newOsNode.fqn}.iso \
            .
            
    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}/kickstart_{newOsNode.fqn}.iso \
            .
    fi
        
else
    echo "Skipping for UEFI boot."
fi
                
            

Creates a UEFI bootable Windows ISO called kickstart_{newOsNode.fqn}.iso from the contents in folder {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}.

Only applies UEFI kickstarts so if any of these parameters are set the string true:

  1. isWin10Uefi
  2. isWinServerUefi

https://unix.stackexchange.com/questions/531012/how-to-modify-an-installation-iso-and-keep-it-bootable

Execute the following script:

                
if {isWin10Uefi} || {isWinServerUefi}
then
    cd "{automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}"
    
    if uname | \
        grep -iq "darwin"
    then
        echo "is macOS"
        export PATH="${HOME}/Parallels/homebrew/bin:$PATH"
        echo "Using $(which xorriso)"
        
        xorriso -as mkisofs \
            -allow-limited-size \
            -iso-level 4 \
            -full-iso9660-filenames \
            -rock \
            -b boot/etfsboot.com \
            -no-emul-boot \
            -boot-load-seg 0 \
            -boot-load-size 8 \
            -hide boot.catalog \
            -eltorito-alt-boot \
            -no-emul-boot \
            -b efi/microsoft/boot/efisys.bin \
            -boot-load-size 1 \
            -udf \
            -untranslated-filenames \
            -disable-deep-relocation \
            -o {automationWorkerLinuxBaseDirectory}/kickstart_{newOsNode.fqn}.iso \
            .
            
    else
        echo "not macOS"
        
        mkisofs \
            -allow-limited-size \
            -iso-level 4 \
            -full-iso9660-filenames \
            -rock \
            -b boot/etfsboot.com \
            -no-emul-boot \
            -boot-load-seg 0 \
            -boot-load-size 8 \
            -hide boot.catalog \
            -eltorito-alt-boot \
            -no-emul-boot \
            -b efi/microsoft/boot/efisys.bin \
            -boot-load-size 1 \
            -udf \
            -untranslated-filenames \
            -disable-deep-relocation \
            -o {automationWorkerLinuxBaseDirectory}/kickstart_{newOsNode.fqn}.iso \
            .
    fi
        
else
    echo "Skipping for BIOS boot."
fi
                
            

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.

  1. isWin10Bios
  2. isWin10Uefi
  3. isWinServerBios
  4. isWinServerUefi

Set 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 "" section in the autounattend.xml file.

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

Copies the contents of the drivers drop in folder at {automationWorkerLinuxBaseDirectory}/drivers-{newOsNode.fqn} to {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}/drivers.

Execute the following script:

                
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}

DRIVERS_DROP_IN_FOLDER="{automationWorkerLinuxBaseDirectory}/drivers-{newOsNode.fqn}"
DESTINATION_DRIVERS_FOLDER="drivers"

mkdir --verbose "${DESTINATION_DRIVERS_FOLDER}"

if [ -d "${DRIVERS_DROP_IN_FOLDER}" ]
then

    cp --verbose --recursive "${DRIVERS_DROP_IN_FOLDER}"/* \
        "${DESTINATION_DRIVERS_FOLDER}"
else
    echo "Drivers drop in folder ${DRIVERS_DROP_IN_FOLDER} does not exist. No drivers copied."
fi
                
            

Creates an ISO at {automationWorkerLinuxBaseDirectory}/drivers_{newVmNode.fqn}.iso containing:

  1. drivers folder
  2. autounattend.xml
  3. post_install_setup.ps1

This works for kickstarts on Linux or macOS with: 1. Windows Desktop 10 2. Windows Server 2016 2. Windows Server 2019 3. Windows Server 2022

Execute the following script:

                
cd {automationWorkerLinuxBaseDirectory}/build-{newOsNode.fqn}

DRIVERS_FOLDER="drivers"
DRIVERS_ISO_NAME="drivers_{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 -o ../${DRIVERS_ISO_NAME} \
        -iso-level 2 -joliet-long -relaxed-filenames \
        -J -l -D -N -V "DRIVERS" "${DRIVERS_FOLDER}" \
        autounattend.xml post_install_wim/post_install_setup.ps1
else
    echo "not macOS"
    
    mkisofs -o ../${DRIVERS_ISO_NAME} \
        -iso-level 3 -udf -joliet-long -relaxed-filenames \
        -J -l -D -N -V "DRIVERS" "${DRIVERS_FOLDER}" \
        autounattend.xml post_install_wim/post_install_setup.ps1
fi
                
            

Completed

You have completed this instruction.

Attune - Powered by ServerTribe

Automate with Attune

Download the Attune Community Edition.

DOWNLOAD!!!

Discuss this Project in Discord

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!

Join NOW!!!