Contents
Create Windows Server 2022 (Win2022) autounattend Single ISO on Windows Worker
Step 1 - Check Input Parameter Values for Windows Server Single ISO Kickstart on Windows Worker
Step 2 - Check if IP Address is in Subnet on Windows Worker
Step 3 - Check if Gateway IP Address is in Subnet on Windows Worker
Step 4 - Verify WSL is Installed
Step 5 - Clean Up Build Files and ISOs on Windows Worker
Step 6 - Deploy Win2022 DVD ISO on Windows Worker
Step 7 - Extract Windows boot.img on Windows Worker
Step 8 - Extract Windows ISO on Windows Worker
Step 9 - Deploy Post Setup PowerShell Script on Windows Worker
Step 10 - Deploy Windows Unattended Config on Windows Worker
Step 11 - Copy Drivers Drop in Folder on Windows Worker
Step 12 - Copy efisys_noprompt.bin into efisys.bin on Windows Worker
Automate This
Use the Attune GUI for your Scripts
You've automated: Create Windows Server 2022 (Win2022) autounattend Single ISO on Windows Worker
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.
Checks if at least one of isWinServerBios or isWinServerUefi is set tot true.
Connect via RDP:
mstsc /admin /v:{automationworkerwindowsnode}
Login as user {automationworkerwindowsuseradministrator} and open a command prompt.
Execute the following script:
if ((-Not ${{isWinServerBios}}) -and `
(-Not ${{isWinServerUefi}})) {
Write-Host "Please set one of 'isWinServerBios' or 'isWinServerUefi' to true to install Windows Server 2016, 2019 or 2022."
exit 1
} else {
Write-Host "Ok."
}
Write-Hosts 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:
Write-Host "IP address={newOsNode.ip}"
Write-Host "subnet={newOsNodeSubnet.subnet}"
Write-Host "netmask={newOsNodeSubnet.netmask}"
#Write-Host "i, IP_OCTET, SUBNET_OCTET, NETMASK_OCTET, WILDCARD_MASK, OCTET_MIN, OCTET_MAX"
$IP_OCTETS = "{newOsNode.ip}".split('.')
$SUBNET_OCTETS = "{newOsNodeSubnet.subnet}".split('.')
$NETMASK_OCTETS = "{newOsNodeSubnet.netmask}".split('.')
for ($i = 0; $i -lt 4; $i++) {
$IP_OCTET = $IP_OCTETS[$i]
$SUBNET_OCTET = $SUBNET_OCTETS[$i]
$NETMASK_OCTET = $NETMASK_OCTETS[$i]
$OCTET_MIN = $SUBNET_OCTET -band $NETMASK_OCTET
$WILDCARD_MASK = 255 - $NETMASK_OCTET
$OCTET_MAX = $SUBNET_OCTET -bor $WILDCARD_MASK
#Write-Host "$i. $IP_OCTET, $SUBNET_OCTET, $NETMASK_OCTET, $WILDCARD_MASK, $OCTET_MIN, $OCTET_MAX"
if ( ($IP_OCTET -ge $OCTET_MIN) -and
($IP_OCTET -le $OCTET_MAX) ) {
Write-Host "Octet number $i, $OCTET_MIN <= $IP_OCTET <= $OCTET_MAX, ok."
} else {
Write-Host "Octet number $i, $OCTET_MIN <= $IP_OCTET <= $OCTET_MAX is false. Not in range of the subnet mask."
exit 1
}
}
Write-Hosts 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:
Write-Host "gateway IP address={newOsNodeSubnet.gateway}"
Write-Host "subnet={newOsNodeSubnet.subnet}"
Write-Host "netmask={newOsNodeSubnet.netmask}"
#Write-Host "i, GATEWAY_OCTET, SUBNET_OCTET, NETMASK_OCTET, WILDCARD_MASK, OCTET_MIN, OCTET_MAX"
$GATEWAY_OCTETS = "{newOsNodeSubnet.gateway}".split('.')
$SUBNET_OCTETS = "{newOsNodeSubnet.subnet}".split('.')
$NETMASK_OCTETS = "{newOsNodeSubnet.netmask}".split('.')
for ($i = 0; $i -lt 4; $i++) {
$GATEWAY_OCTET = $GATEWAY_OCTETS[$i]
$SUBNET_OCTET = $SUBNET_OCTETS[$i]
$NETMASK_OCTET = $NETMASK_OCTETS[$i]
$OCTET_MIN = $SUBNET_OCTET -band $NETMASK_OCTET
$WILDCARD_MASK = 255 - $NETMASK_OCTET
$OCTET_MAX = $SUBNET_OCTET -bor $WILDCARD_MASK
#Write-Host "$i. $GATEWAY_OCTET, $SUBNET_OCTET, $NETMASK_OCTET, $WILDCARD_MASK, $OCTET_MIN, $OCTET_MAX"
if ( ($GATEWAY_OCTET -ge $OCTET_MIN) -and
($GATEWAY_OCTET -le $OCTET_MAX) ) {
Write-Host "Octet number $i, $OCTET_MIN <= $GATEWAY_OCTET <= $OCTET_MAX, ok."
} else {
Write-Host "Octet number $i, $OCTET_MIN <= $GATEWAY_OCTET <= $OCTET_MAX is false. Not in range of the subnet mask."
exit 1
}
}
Check if Windows Subsystem for Linux is installed.
Execute the following script:
wsl --list
if (echo $?) {
Write-Host "WSL is installed."
} else {
Write-Host "WSL is not installed."
exit 1
}
Deletes the folder at C:\attuneautomationworker\build-{newOsNode.fqn}.
Execute the following script:
$DIR="C:\attuneautomationworker\build-{newOsNode.fqn}"
if (Test-Path $DIR) {
Remove-Path -Recursive $DIR
}
Deploys Windows Server 2022 ISO to /c$/attuneautomationworker/build-winpe-iso.
Download from https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022.
Copy the File(s) Win2022_ISO.tar to the target node.
Deploy the File(s) here:
/c$/attuneautomationworker/build-{newOsNode.fqn}
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:
The bash script file needs to have the Windows default carriage return line feed CRLF replaced with Linux default line feeds LF https://stackoverflow.com/questions/19127741/replace-crlf-using-powershell.
Execute the following script:
if ((${{isWin10Bios}}) -or `
(${{isWinServerBios}})) {
$ISO_BUILD="C:\attuneautomationworker"
$BUILD_DIR="$ISO_BUILD\build-{newOsNode.fqn}"
Set-Location $BUILD_DIR
$scriptContent=@'
# 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;
'@
# Replace CRLF with LF
$scriptContent = $scriptContent.replace("`r`n","`n")
$FILE = "attune_wsl_extract_boot_img.sh"
Set-Content -Path $FILE -NoNewline -Value $scriptContent
wsl -d Ubuntu --user root --exec bash "${FILE}"
if ($LASTEXITCODE -ne 0) {
Write-Error 'Failed to extract boot.img'
}
Remove-Item "${FILE}"
} else {
Write-Host "Skipping for UEFI ISO creation."
}
Extracts the Windows ISO.
Execute the following script:
$ISO_BUILD="C:\attuneautomationworker"
$BUILD_DIR="$ISO_BUILD\build-{newOsNode.fqn}"
Set-Location $BUILD_DIR
$ISO_WILDCARD="*.iso"
if (test-Path "${ISO_WILDCARD}" -pathtype leaf) {
$ISO=(dir $ISO_WILDCARD).name
Write-Host "Found ISO ${ISO}. Extracting it."
& 'C:\Program Files\7-Zip\7z.exe' x ".\${ISO}"
Write-Host "Removing ${ISO}"
Remove-Item "${ISO}"
} else {
Write-Error "No ISO found for extracting."
}
Creates a post_install.wim Windows Imaging Format file on Windows Worker.
The purpose of this file is to overlay onto the C drive any files we want
for the Windows Installer to use. In this case we want to deploy a post
install setup PowerShell script at C:\post_install_setup.ps1 that is
called by autounattend.xml <FirstLogonCommands>'s section.
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.
{automationWorkerWindowsBaseDirectorySharePath}/build-{newOsNode.fqn}/post_install_wim, 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.
Copy the File(s) Windows_Unattended_config_v2.tar to the target node.
{automationWorkerWindowsBaseDirectorySharePath}/build-{newOsNode.fqn}, relative to the home directory
Copies the contents of the drivers drop in folder at C:\attuneautomationworker\drivers-{newOsNode.fqn} to C:\attuneautomationworker\build-{newOsNode.fqn}\drivers.
Execute the following script:
$ISO_BUILD="C:\attuneautomationworker"
$BUILD_DIR="${ISO_BUILD}\build-{newOsNode.fqn}"
Set-Location "${BUILD_DIR}"
$DRIVERS_DROP_IN_FOLDER = "C:\attuneautomationworker\drivers-{newOsNode.fqn}"
$DESTINATION_DRIVERS_FOLDER = "drivers"
if ( -Not (Test-Path "${DESTINATION_DRIVERS_FOLDER}") ) {
New-Item "${DESTINATION_DRIVERS_FOLDER}" -ItemType Directory
}
if ( Test-Path "${DRIVERS_DROP_IN_FOLDER}" ) {
Copy-Item -Recurse -Path "${DRIVERS_DROP_IN_FOLDER}\*" `
-Destination "${DESTINATION_DRIVERS_FOLDER}"
} else {
Write-Host "Drivers drop in folder ${DRIVERS_DROP_IN_FOLDER} does not exist. No drivers copied."
}
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 . . . .".
efisys_noprompt.bin does not have the prompt "Pres any key to boot from CDROM".
Execute the following script:
if ( ${{isWin10Uefi}} -or ${{isWinServerUefi}} ) {
$ISO_BUILD="C:\attuneautomationworker"
$BUILD_DIR="$ISO_BUILD\build-{newOsNode.fqn}"
Set-Location $BUILD_DIR
Set-Location efi\microsoft\boot
Copy-Item -Path .\efisys_noprompt.bin -Destination .\efisys.bin
} else {
Write-Host "Skipping for BIOS ISO creation."
}
Creates a BIOS bootable Windows ISO called kickstart_{newOsNode.fqn}.iso from the contents in folder C:\attuneautomationworker\build-{newOsNode.fqn}.
Only applies BIOS kickstarts so if any of these parameters are set the string true:
isWin10BiosisWinServerBiosExecute the following script:
$ISO_BUILD="C:\attuneautomationworker"
$BUILD_FOLDER="build-{newOsNode.fqn}"
# This is so we place the "attune_wsl_create_bios_boot_iso.sh" outside the $BUILD_FOLDER
Set-Location $ISO_BUILD
if (${{isWin10Bios}} -or `
${{isWinServerBios}}) {
$scriptContent=@"
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 kickstart_{newOsNode.fqn}.iso \
'${BUILD_FOLDER}'
"@
# Replace CRLF with LF
$scriptContent = $scriptContent.replace("`r`n","`n")
$FILE = "attune_wsl_create_bios_boot_iso.sh"
Set-Content -Path $FILE -NoNewline -Value $scriptContent
wsl -d Ubuntu --user root --exec bash "${FILE}"
if ($LASTEXITCODE -ne 0) {
Write-Error 'Failed to create $ISO_BUILD\kickstart_{newOsNode.fqn}.iso'
}
Remove-Item "${FILE}"
} else {
Write-Host "Skipping for UEFI boot."
}
Creates a UEFI bootable Windows ISO called kickstart_{newOsNode.fqn}.iso from the contents in folder C:\attuneautomationworker\build-{newOsNode.fqn}.
Only applies to UEFI kickstarts so if any of these parameters are set the string 'true':
isWin10UefiisWinServerUefiExecute the following script:
$ISO_BUILD="C:\attuneautomationworker"
$BUILD_FOLDER="build-{newOsNode.fqn}"
# This is so we place the "tmpBash.sh" outside the $BUILD_FOLDER
Set-Location $ISO_BUILD
if (${{isWin10Uefi}} -or `
${{isWinServerUefi}}) {
$scriptContent=@"
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 kickstart_{newOsNode.fqn}.iso \
'${BUILD_FOLDER}'
"@
# Replace CRLF with LF
$scriptContent = $scriptContent.replace("`r`n","`n")
$FILE = "attune_wsl_create_uefi_boot_iso.sh"
Set-Content -Path $FILE -NoNewline -Value $scriptContent
wsl -d Ubuntu --user root --exec bash "${FILE}"
if ($LASTEXITCODE -ne 0) {
Write-Error 'Failed to extract boot.img'
}
} else {
Write-Host "Skipping for BIOS boot."
}
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!