summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/crashdetect/CrashDetectCreateUsb.cmd189
-rw-r--r--.github/crashdetect/CrashDetectOsReinstall.cmd258
-rw-r--r--.github/crashdetect/CrashDetectSetupGuide.md256
-rw-r--r--.github/crashdetect/Unattend.xml64
-rw-r--r--.github/pdu/Pdu.ps1250
-rw-r--r--.github/pdu/PduReadme.md65
6 files changed, 1082 insertions, 0 deletions
diff --git a/.github/crashdetect/CrashDetectCreateUsb.cmd b/.github/crashdetect/CrashDetectCreateUsb.cmd
new file mode 100644
index 00000000..571f0393
--- /dev/null
+++ b/.github/crashdetect/CrashDetectCreateUsb.cmd
@@ -0,0 +1,189 @@
+@echo off
+setlocal
+
+set WINPE_DRIVE=A
+set WINUSB_DRIVE=B
+set EXITCODE=0
+
+rem Pre-check
+if not exist "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\DISM\dism.exe" (
+ echo ERROR: Missing DISM tool!
+ goto error
+)
+if not exist "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim" (
+ echo ERROR: Missing winpe.wim image!
+ goto error
+)
+if not exist "C:\WinPE_USB\Scripts\CrashDetectOsReinstall.cmd" (
+ echo ERROR: Missing script C:\WinPE_USB\Scripts\CrashDetectOsReinstall.cmd!
+ goto error
+)
+if not exist "C:\WinPE_USB\Scripts\Unattend.xml" (
+ echo ERROR: Missing XML C:\WinPE_USB\Scripts\Unattend.xml!
+ goto error
+)
+if not exist "C:\WinPE_USB\Images\install.wim" (
+ echo ERROR: Missing WIM C:\WinPE_USB\Images\install.wim!
+ goto error
+)
+
+rem Environment setup.
+echo Setting up environment for ADK tools...
+cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools>"
+call DandISetEnv.bat
+echo Done setting up environment.
+
+rem Ask for the USB disk number displayed in Diskpart.
+echo Displaying detected disk drives..
+echo Creating DiskPart script...
+(
+echo list disk
+) > C:\WinPE_USB\diskpart.txt
+diskpart /s C:\WinPE_USB\diskpart.txt
+del C:\WinPE_USB\diskpart.txt
+echo(
+echo(
+echo Note that Disk 0 is often the OS drive you do NOT want to format!
+echo(
+echo Ensure drive letters %WINPE_DRIVE%: and %WINUSB_DRIVE%: are not currently assigned to other drives!
+echo It's ok if it's assigned to the target USB.
+echo(
+set /p USBDISK=Enter the Disk Number of the USB drive you want to make WinPE bootable:
+echo(
+echo Disk %USBDISK% selected.
+
+rem Create a USB drive with WinPE and data partitions.
+echo(
+echo WARNING!!!: VERIFY DISK %USBDISK% IS THE CORRECT USB DISK TO FORMAT!
+choice /C YN /M "ARE YOU SURE YOU WANT TO FORMAT DISK %USBDISK%?"
+echo(
+if %errorlevel% equ 2 (
+ echo You chose NO, exiting without modifying USB key.
+ exit /b 0
+)
+if %errorlevel% equ 1 (
+ echo You chose YES, proceeding with formatting USB key.
+)
+
+:dism
+rem Update startnet.cmd autorun script in WinPE boot image (winpe.wim).
+cd /d "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64"
+echo(
+if not exist "C:\WinPE_USB\WinPE_amd64\mount" (
+ echo Creating temp folders C:\WinPE_USB\WinPE_amd64\mount...
+ mkdir "C:\WinPE_USB\WinPE_amd64\mount"
+)
+echo Mounting WinPE image to modify...
+Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_USB\WinPE_amd64\mount"
+if errorlevel 1 (
+ echo ERROR: DISM failed to mount ImageFile:"en-us\winpe.wim"!
+ goto error
+)
+echo Done mounting winpe.wim image.
+echo Updating startnet.cmd autorun script in WinPE boot image...
+(
+echo wpeinit
+echo.
+echo @echo off
+echo rem Find USB drive.
+echo for %%%%D in (D E F G H I J K L M N O P Q R S T U V W Y Z^) do ^(
+echo if exist %%%%D:Scripts\CrashDetectOsReinstall.cmd ^(
+echo call %%%%D:Scripts\CrashDetectOsReinstall.cmd
+echo goto EOF
+echo ^)
+echo ^)
+) > "C:\WinPE_USB\WinPE_amd64\mount\Windows\System32\startnet.cmd"
+echo Done adding CrashDetectOsReinstall.cmd to startnet.cmd.
+echo Unmounting WinPE image with committed changes...
+Dism /Unmount-Image /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" /commit
+if errorlevel 1 (
+ echo ERROR: DISM failed to unmount ImageFile:"en-us\winpe.wim"!
+ echo USB drive have not been touched yet.
+ goto error
+)
+echo Done unmounting winpe.wim image.
+
+rem Delete temp "WinPE_amd64" folder, else the "copype.cmd" below will fail if the folder is already present.
+rmdir /s /q "C:\WinPE_USB\WinPE_amd64"
+echo Deleted temp folder "C:\WinPE_USB\WinPE_amd64".
+echo(
+echo Wiping out USB and creating 2 partitions...
+echo Creating DiskPart script...
+(
+echo select disk %USBDISK%
+echo clean
+echo create partition primary size=2048
+echo active
+echo format fs=FAT32 quick label="WinPE"
+echo assign letter=%WINPE_DRIVE%
+echo create partition primary
+echo format fs=NTFS quick label="WinUSB"
+echo assign letter=%WINUSB_DRIVE%
+) > C:\WinPE_USB\diskpart.txt
+echo Partitioning USB...
+diskpart /s C:\WinPE_USB\diskpart.txt
+if errorlevel 1 (
+ echo ERROR: DiskPart failed during partitioning and formatting USB!
+ del C:\WinPE_USB\diskpart.txt
+ goto error
+)
+del C:\WinPE_USB\diskpart.txt
+echo Done partitioning and formatting USB.
+echo(
+rem The "copype.cmd" script will create working directory "WinPE_amd64", it will fail if directory already exist.
+echo Copying WinPE working files to "C:\WinPE_USB\WinPE_amd64"...
+call copype.cmd amd64 "C:\WinPE_USB\WinPE_amd64"
+if errorlevel 1 (
+ echo ERROR: Script "copype.cmd" failed to copy working files!
+ goto error
+)
+echo Done copying WinPE files.
+echo(
+rem Install WinPE to the USB and make it bootable.
+echo Creating bootable WinPE USB...
+call Makewinpemedia.cmd /ufd /f "C:\WinPE_USB\WinPE_amd64" "%WINPE_DRIVE%:" /bootex
+if errorlevel 1 (
+ echo ERROR: Script "Makewinpemedia.cmd" failed to make WinPE USB bootable!
+ goto error
+)
+echo Done, WinPE USB drive is now bootable.
+echo(
+rem Copy Unattend.xml, scripts and install.wim over to USB
+echo Copying Unattend.xml and scripts over to USB...
+xcopy "C:\WinPE_USB\Scripts\" "%WINUSB_DRIVE%:\Scripts\" /E /I /R /Y
+if errorlevel 1 (
+ echo ERROR: Failed copying scripts from "C:\WinPE_USB\Scripts\" to USB!
+ goto error
+)
+echo Done copying script files.
+echo(
+echo Copying install.wim over to USB...this could take a while...
+robocopy "C:\WinPE_USB\Images" "%WINUSB_DRIVE%:\Images" install.wim /ETA /J
+if %errorlevel% geq 8 (
+ echo ERROR: Failed copying install.wim from "C:\WinPE_USB\Images\" to USB!
+ goto error
+)
+echo Done copying WIM file.
+echo(
+goto cleanup
+
+:error
+set EXITCODE=1
+goto cleanup
+
+:cleanup
+rem Clean up any temp folders.
+if exist "C:\WinPE_USB\WinPE_amd64" (
+ rmdir /s /q "C:\WinPE_USB\WinPE_amd64"
+ echo Cleaned up temp folder "C:\WinPE_USB\WinPE_amd64".
+)
+
+:done
+if %EXITCODE% equ 0 (
+ echo(
+ echo SUCCESSFULLY CREATED BOOTABLE WINPE USB DRIVE.
+) else (
+ echo(
+ echo FAILED CREATING BOOTABLE WINPE USB DRIVE!
+)
+endlocal & exit /b %EXITCODE% \ No newline at end of file
diff --git a/.github/crashdetect/CrashDetectOsReinstall.cmd b/.github/crashdetect/CrashDetectOsReinstall.cmd
new file mode 100644
index 00000000..faebb443
--- /dev/null
+++ b/.github/crashdetect/CrashDetectOsReinstall.cmd
@@ -0,0 +1,258 @@
+@echo off
+setlocal EnableExtensions EnableDelayedExpansion
+
+echo CrashDetectOsReinstall.cmd...START
+
+echo Searching for the USB drive volume letter...
+set "USB="
+
+for %%D in (D E F G H I J K L M N O P Q R S T U V W Y Z) do (
+ if exist "%%D:\Scripts\CrashDetectOsReinstall.cmd" (
+ set "USB=%%D"
+ echo Found USB at drive volume letter !USB!:
+ )
+)
+
+if not defined USB (
+ echo ERROR: Did not find USB drive volume letter
+ goto error
+)
+
+if not exist "!USB!:\Logs" (
+ echo Creating Logs directory on USB
+ mkdir "!USB!:\Logs"
+)
+set "LOG=!USB!:\Logs\CrashDetectOsReinstall.log"
+echo Created log file "%LOG%" on USB
+echo [%DATE% %TIME%] CrashDetectOsReinstall.cmd...START >> "%LOG%"
+echo [%DATE% %TIME%] Found USB at drive volume letter !USB!: >> "%LOG%"
+
+set "FLAG_RETRIES=!USB!:\Logs\Retries.flg"
+set "FLAG_INSTALLOS=!USB!:\Logs\InstallOs.flg"
+set "FLAG_DEPLOYOSDONE=!USB!:\Logs\DeployOsDone.flg"
+
+
+:installos
+if exist "%FLAG_INSTALLOS%" (
+ if exist "%FLAG_DEPLOYOSDONE%" (
+ echo OS reinstall done.
+ echo [%DATE% %TIME%] OS reinstall done. >> "%LOG%"
+ del "%FLAG_INSTALLOS%" >> "%LOG%" 2>&1
+ del "%FLAG_DEPLOYOSDONE%" >> "%LOG%" 2>&1
+ goto reboot
+ )
+ echo Reinstalling OS...
+ echo [%DATE% %TIME%] Reinstalling OS... >> "%LOG%"
+ goto deployos
+)
+
+
+:detectcrash
+if exist "C:\Windows\Minidump\" (
+ echo OS crashed on last reboot into the OS!
+ echo [%date% %time%] OS crashed on last reboot into the OS! >> "%LOG%"
+
+ set "MININAME="
+ for %%F in ("C:\Windows\Minidump\*.dmp") do (
+ set "MININAME=%%~nF"
+ echo Minidump filename: !MININAME! >> "%LOG%"
+ )
+
+ echo Backing up Minidump files...
+ copy /y "C:\Windows\Minidump\*.dmp" "!USB!:\Logs" >> "%LOG%" 2>&1
+ if !errorlevel! neq 0 (
+ echo ERROR: Failed to back up Mini dump file
+ echo [%date% %time%] ERROR: Failed to back up Mini dump file >> "%LOG%"
+ )
+ rmdir /s /q "C:\Windows\Minidump" >> "%LOG%" 2>&1
+ if !errorlevel! neq 0 (
+ echo ERROR: Failed to delete Minidump folder
+ echo [%date% %time%] Failed to delete Minidump folder >> "%LOG%"
+ )
+
+ if exist "C:\Windows\MEMORY.DMP" (
+ if defined MININAME (
+ ren "C:\Windows\MEMORY.DMP" "MEMORY-!MININAME!.DMP" >> "%LOG%" 2>&1
+ )
+ if !errorlevel! neq 0 (
+ echo ERROR: Failed to rename MEMORY.DMP file
+ echo [%date% %time%] ERROR: Failed to rename MEMORY.DMP file >> "%LOG%"
+ echo Backing up MEMORY.DMP file...
+ copy /y "C:\Windows\MEMORY.DMP" "!USB!:\Logs" >> "%LOG%" 2>&1
+ ) else (
+ echo Backing up MEMORY-!MININAME!.DMP file...
+ copy /y "C:\Windows\MEMORY-!MININAME!.DMP" "!USB!:\Logs" >> "%LOG%" 2>&1
+ )
+ if !errorlevel! neq 0 (
+ echo ERROR: Failed to back up MEMORY.DMP file
+ echo [%date% %time%] ERROR: Failed to back up MEMORY.DMP file >> "%LOG%"
+ )
+ )
+
+ echo Done trying to back up files to USB
+ echo [%date% %time%] Done trying to back up files to USB >> "%LOG%"
+ goto retry
+) else (
+ rem If OS crashed just now, it will be detected on next reboot.
+ rem Minidump folder used for crash detection is not created yet on automatic first crash reboot until OS is loaded.
+ echo No OS crash on last reboot into the OS.
+ echo [%date% %time%] No OS crash on last reboot into the OS. >> "%LOG%"
+ if exist %FLAG_RETRIES% (
+ del %FLAG_RETRIES% >> "%LOG%" 2>&1
+ )
+ goto reboot
+)
+
+
+:retry
+set "TRIES=0"
+rem Retries are always one less than actual crashes because first crash is not detected.
+set "MAX_RETRIES=2"
+
+if not exist "%FLAG_RETRIES%" (
+ echo Creating "%FLAG_RETRIES%" with default retries set to 0 >> "%LOG%"
+ echo RETRIES=0 > "%FLAG_RETRIES%"
+)
+
+for /f "tokens=1,2 delims==" %%A in (%FLAG_RETRIES%) do (
+ if /i "%%A"=="RETRIES" (
+ set "TRIES=%%B" >> "%LOG%" 2>&1
+ )
+)
+
+set /a TRIES+=0 2>nul >> "%LOG%" 2>&1
+set /a TRIES+=1 >> "%LOG%" 2>&1
+echo RETRIES=!TRIES! > %FLAG_RETRIES%
+
+echo Current OS boot retries: !TRIES!
+echo Current OS boot retries: !TRIES! >> "%LOG%"
+if !TRIES! GEQ %MAX_RETRIES% (
+ echo Max %MAX_RETRIES% retries reached, reinstalling OS...
+ del %FLAG_RETRIES% >> "%LOG%" 2>&1
+ type nul > %FLAG_INSTALLOS%
+ goto installos
+) else (
+ echo Max %MAX_RETRIES% retries allowed, booting into OS...
+ goto reboot
+)
+
+
+:deployos
+rem Image index is the OS edition to install from a multi-edition OS install image.
+rem For "Windows 11 25H2" image, "Windows 11 Pro" is the 6th item on the list of editions available.
+rem Adjust accordingly to install other OS editions.
+rem For single edition OS images, set index to 1.
+set "IMAGE_INDEX=6"
+set "TARGET_DISK=0"
+set "SYSTEM_DRIVE=S"
+set "SYSTEM_LABEL=System"
+set "TARGET_DRIVE=W"
+set "TARGET_LABEL=TestOS"
+set "INSTALL_WIM=install.wim"
+set "UNATTEND_XML=Unattend.xml"
+
+echo Setting flag InstallOs.flg for CrashDetectOsReinstall.cmd autorun script to detect OS install. >> "%LOG%"
+type nul > "%FLAG_INSTALLOS%"
+
+echo [1/8] Creating DiskPart script...
+echo [%DATE% %TIME%] [1/8] Creating DiskPart script... >> "%LOG%"
+(
+echo select disk "%TARGET_DISK%"
+echo clean
+echo convert gpt
+echo create partition efi size=100
+echo format quick fs=fat32 label="%SYSTEM_LABEL%"
+echo assign letter="%SYSTEM_DRIVE%"
+echo create partition msr size=16
+echo create partition primary
+echo format quick fs=ntfs label="%TARGET_LABEL%"
+echo assign letter="%TARGET_DRIVE%"
+) > X:\diskpart.txt
+
+echo [2/8] Partitioning target disk...
+echo [%DATE% %TIME%] [2/8] Partitioning target disk... >> "%LOG%"
+diskpart /s X:\diskpart.txt >> "%LOG%" 2>&1
+if errorlevel 1 (
+ echo ERROR: DiskPart failed. See %LOG%
+ goto error
+)
+
+echo [3/8] Applying OS WIM image...
+echo [%DATE% %TIME%] [3/8] Applying image... >> "%LOG%"
+dism /Apply-Image /ImageFile:"!USB!:\Images\%INSTALL_WIM%" /Index:"%IMAGE_INDEX%" /ApplyDir:"%TARGET_DRIVE%":\ >> "%LOG%" 2>&1
+if errorlevel 1 (
+ echo ERROR: DISM apply failed. See %LOG%
+ goto error
+)
+
+echo [4/8] Copying "%UNATTEND_XML%"...
+echo [%DATE% %TIME%] [4/8] Copying %UNATTEND_XML%... >> "%LOG%"
+if not exist "%TARGET_DRIVE%:\Windows\Panther" (
+ mkdir "%TARGET_DRIVE%:\Windows\Panther" >> "%LOG%" 2>&1
+)
+copy /y "!USB!:\Scripts\%UNATTEND_XML%" "%TARGET_DRIVE%:\Windows\Panther\%UNATTEND_XML%" >> "%LOG%" 2>&1
+if errorlevel 1 (
+ echo ERROR: Failed to copy %UNATTEND_XML%. See %LOG%
+ echo [%DATE% %TIME%] ERROR: Failed to copy %UNATTEND_XML%. >> %LOG%
+ goto error
+)
+
+echo [5/8] Creating boot files...
+echo [%DATE% %TIME%] [5/8] Creating boot files... >> "%LOG%"
+bcdboot W:\Windows /s S: /f UEFI >> "%LOG%" 2>&1
+if errorlevel 1 (
+ echo ERROR: BCDBOOT failed. See %LOG%
+ goto error
+)
+
+echo [6/8] Setting one-time bootsequence to OS boot manager...
+echo [%DATE% %TIME%] [6/8] Setting one-time bootsequence to OS boot manager... >> "%LOG%"
+bcdedit /set {fwbootmgr} bootsequence {bootmgr}
+echo bcdedit /set {fwbootmgr} bootsequence {bootmgr} >> "%LOG%"
+if errorlevel 1 (
+ echo ERROR: BCDEDIT /set {fwbootmgr} bootsequence {bootmgr} failed. See "%LOG%"
+ goto error
+)
+
+echo [7/8] Deployment complete.
+echo [%DATE% %TIME%] [7/8] Deployment complete. >> "%LOG%"
+echo Deployment complete. >> "%LOG%"
+echo Setting flag DeployOsDone.flg for script to detect OS install complete and boot into OS.
+type nul > "%FLAG_DEPLOYOSDONE%"
+
+echo [8/8] Rebooting into OS in 10sec...
+echo [%DATE% %TIME%] [8/8] Rebooting into OS in 10sec... >> "%LOG%"
+rem Simulate timeout with ping (10 sec)
+ping -n 11 127.0.0.1 >nul
+wpeutil reboot >> "%LOG%" 2>&1
+
+
+:reboot
+echo Rebooting into OS in 10sec...
+echo [%DATE% %TIME%] Rebooting into OS... >> "%LOG%"
+rem Force next boot into Windows boot manager.
+bcdedit /set {fwbootmgr} bootsequence {bootmgr} >> "%LOG%" 2>&1
+if errorlevel 1 (
+ echo ERROR: BCDEDIT /set {fwbootmgr} bootsequence {bootmgr} - failed. See "%LOG%"
+ goto error
+)
+rem Disable WinRE prompt to attempt system recovery, which requires user intervention.
+bcdedit /set {default} recoveryenabled no >> "%LOG%" 2>&1
+if errorlevel 1 (
+ echo ERROR: BCDEDIT /set {default} recoveryenabled no - failed. See "%LOG%"
+)
+rem Simulate timeout with ping (10 sec)
+ping -n 11 127.0.0.1 >nul
+wpeutil reboot >> "%LOG%" 2>&1
+
+
+:error
+echo CrashDetectOsReinstall.cmd...ERROR! See "%LOG%"
+echo [%DATE% %TIME%] CrashDetectOsReinstall.cmd...ERROR! >> "%LOG%"
+exit /b 1 >> "%LOG%" 2>&1
+
+
+:done
+echo CrashDetectOsReinstall.cmd...DONE!
+echo [%DATE% %TIME%] CrashDetectOsReinstall.cmd...DONE! >> "%LOG%"
+exit /b 0 >> "%LOG%" 2>&1
diff --git a/.github/crashdetect/CrashDetectSetupGuide.md b/.github/crashdetect/CrashDetectSetupGuide.md
new file mode 100644
index 00000000..dc974507
--- /dev/null
+++ b/.github/crashdetect/CrashDetectSetupGuide.md
@@ -0,0 +1,256 @@
+# Crash Detect USB Setup Guide: <br>Automating Crash Detection and OS Reinstall of Target Test Systems
+
+---
+
+## A) Overview
+This guide walks through setting up a new bootable WinPE USB drive using:
+
+- A **Host Controller** (to build the USB)
+- A **bootable WinPE USB** (automatic crash detection and OS reinstall)
+- A **target test system**
+
+### High-level flow
+1. Download Windows image (ISO)
+2. Install Windows ADK + WinPE add-on
+3. Create bootable WinPE USB
+4. Copy image + scripts to USB
+5. Boot up target system
+6. OPTIONAL: Install OS on new Target System
+7. OPTIONAL: Add a Custom Script to Windows Setup
+
+---
+
+## B) Requirements
+
+### Host Controller
+- Windows 11 25H2
+- Administrator privileges
+- USB drive (>= 64GB recommended)
+- Internet connection
+
+### Target System
+- Windows 11 25H2
+- BIOS boot priority set to **USB boot** and **Secure Boot disabled**
+- Windows System failure recovery set to **"Automatically restart"**
+- Willing to wipe disk (automatic OS reinstall from crash)
+
+---
+
+## C) Download Required Software and Scripts onto the Host Controller
+
+### Windows OS Image (ISO)
+- [Download Windows 11 (official)](https://www.microsoft.com/en-us/software-download/windows11)
+- Go to section "Download Windows 11 Disk Image (ISO) for x64 devices".
+- Select the option "Windows 11 (multi-edition ISO for x64 devices)".
+- Click "Confirm" button.
+- Section "Select the product language" should appear.
+- Select your language option. (Ex: "English (United States)")
+- Click "Confirm" button.
+- Section "Download - Windows 11 English" should appear.
+- Click "64-bit Download" button.
+
+Mount ISO:
+- In File Explorer, go to the location you downloaded the ISO file `Win11_25H2_English_x64_v2.iso` to.
+- Right-click on the ISO file and select "Mount".
+ - If the "Open File - Security Warning" prompt pops up after a minute then click "Open".
+ - (The prompt may be hidden behind other Windows.)
+- Create new folder and subfolder `C:\WinPE_USB\Images`.
+- Go to the `%MountDriveLetter%:\sources` folder and copy the **`install.wim`** file to **`C:\WinPE_USB\Images`**.
+ - This is the Windows 11 OS image file that the DISM tool will need to deploy the OS.
+ - This file will be copied over to the USB later after bootable WinPE USB creation.
+- Right-click on the %MountDriveLetter% and select "Eject" to unmount the ISO image.
+
+---
+
+### Windows Assessment and Deployment Kit (Deployment Tools) & Windows PE Add-on
+- [Download Windows ADK & WinPE Add-on](https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install)
+- Go to section "Download the ADK 10.1.26100.2454 (December 2024)".
+- Click on the link "Download the Windows ADK 10.1.26100.2454 (December 2024)" to download the `adksetup.exe` installer.
+- Click on the link "Download the Windows PE add-on for the Windows ADK 10.1.26100.2454 (December 2024)" to download the `adkwinpesetup.exe` installer.
+
+Install ADK:
+- Double-click on the `adksetup.exe` from the location you downloaded the file to launch the installer.
+- "Specify Location" page, click "Next", to install at default location.
+- "Windows Kits Privacy" page, select your privacy option, click "Next".
+- "License Agreement" page, click "Accept".
+- "Select the features you want to install" page, confirm "Deployment Tools" is checked, then click "Install".
+- If "User Account Control" prompt appears, click "Yes" to begin installation process.
+- "Installing features..." page, wait for installation process to complete.
+- "Welcome to the Windows Assessment and Deployment Kit!" page, click "Close".
+
+Install WinPE Add-on: <br>**Important:** Install **ADK first**, then WinPE add-on
+- Double-click on the `adkwinpesetup.exe` from the location you downloaded the file to launch the installer.
+- "Specify Location" page, click "Next", to install at default location.
+- "Windows Kits Privacy" page, select your privacy option, click "Next".
+- "License Agreement" page, click "Accept".
+- "Select the features you want to install" page, confirm "Windows Preinstallation Environment (Windows PE)" is checked, then click "Install".
+- If "User Account Control" prompt appears, click "Yes" to begin installation process.
+- "Installing features..." page, wait for installation process to complete.
+- "Welcome to the Windows Assessment and Deployment Kit Windows Preinstallation Environment Add-ons!" page, click "Close".
+
+---
+
+### Unattend and Script Files from GitHub
+- Download files from [Windows-driver-samples/tree/main/.github/crashdetect](https://github.com/microsoft/Windows-driver-samples/tree/main/.github/crashdetect)
+- Create directory **`C:\WinPE_USB\Scripts\`** and copy the following downloaded files to there.
+ - `CrashDetectCreateUsb.cmd`
+ - `CrashDetectOsReinstall.cmd`
+ - `Unattend.xml`
+
+---
+
+## D) Create Bootable WinPE USB
+- **TIP:** It's a good idea to make a backup copy of the original **"winpe.wim"** image file before editing it in the following steps.
+ - `C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim`
+
+- Plug a USB drive into the Host Controller.
+- Check to make sure drive letters **A:** and **B:** are not currently used by any other drive. If used by the target USB drive, it's okay.
+- Confirm the folder **`C:\WinPE_USB`** and its subfolders **`Scripts`** and **`Images`** exist.
+- Confirm the **`Scripts`** subfolder contains the following files that were downloaded from previous steps.
+ - `CrashDetectOsReinstall.cmd`
+ - `Unattend.xml`
+- Confirm the **`Images`** subfolder contains the Win11 OS image file.
+ - `install.wim`
+
+### OPTION 1: Use the `CrashDetectCreateUsb.cmd` script to create the USB automatically.
+- Start a `Command Prompt` running as administrator.
+- Run the script by typing the following line into the Command Prompt.
+```cmd
+C:\WinPE_USB\Scripts\CrashDetectCreateUsb.cmd
+```
+- The script will display a list of detected disk drives, usually Disk 0 is the OS disk, DO NOT select that disk.
+- Prompt 1: will ask you to enter the Disk number of your USB drive.
+- Prompt 2: will ask you to confirm one last time before wiping out the USB drive.
+- The last step will copy over the `install.wim` OS image to the USB, which could take a while.
+
+### OPTION 2: Follow the steps below to create the USB manually.
+#### 1. Make sure your PC has the ADK and ADK Windows PE add-on installed.
+ - Start the `Deployment and Imaging Tools Environment` running as administrator.
+
+#### 2. Update the `startnet.cmd` autorun script in the WinPE boot image.
+ - Mount the WinPE boot image (`winpe.wim`) using DISM.
+ - Adds the `CrashDetectOsReinstall.cmd` script to the `startnet.cmd` script.
+```cmd
+(
+echo wpeinit
+echo.
+echo @echo off
+echo REM Find USB drive.
+echo for %%D in (D E F G H I J K L M N O P Q R S T U V W Y Z^) do ^(
+echo if exist %%D:Scripts\CrashDetectOsReinstall.cmd ^(
+echo call %%D:Scripts\CrashDetectOsReinstall.cmd
+echo goto EOF
+echo ^)
+echo ^)
+) > "C:\WinPE_USB\WinPE_amd64\mount\Windows\System32\startnet.cmd"
+```
+ - Unmount the WinPE image using DISM.
+```cmd
+Dism /Unmount-Image /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" /commit
+```
+ - Delete folder `C:\WinPE_USB\WinPE_amd64`, else the `copype.cmd` below will fail if the folder is already present.
+```cmd
+rmdir /s /q "C:\WinPE_USB\WinPE_amd64"
+```
+
+#### 3. Create and format a multiple partition USB drive.
+ - Attach a USB large enough for 2GB WinPE partition + WinUSB partition (Win11 WIM 8GB + Memory dump files 16GB-64GB + Scripts).
+ - Enter the following commands into the command prompt.
+```cmd
+diskpart
+list disk
+select disk X (where X is your USB drive)
+clean
+create partition primary size=2048
+active
+format fs=FAT32 quick label="WinPE"
+assign letter=A
+create partition primary
+format fs=NTFS quick label="WinUSB"
+assign letter=B
+exit
+```
+
+#### 4. Create a bootable Windows PE USB drive.
+ - Copying WinPE boot files to a working directory.
+```cmd
+copype.cmd amd64 "C:\WinPE_USB\WinPE_amd64"
+```
+ - Copy the WinPE files to the WinPE partition on USB.
+```cmd
+MakeWinPEMedia.cmd /UFD /F "C:\WinPE_USB\WinPE_amd64" "A:" /bootex
+```
+
+---
+
+#### 5. Copy scripts and OS install image over to WinUSB partition on USB.
+ - Copy Script files over to USB.
+```cmd
+xcopy "C:\WinPE_USB\Scripts\" "B:\Scripts\" /E /I /R /Y
+```
+ - Copy Windows 11 OS WIM file over to USB, this could take a while...
+```cmd
+robocopy "C:\WinPE_USB\Images" "B:\Images" install.wim /ETA /J
+```
+
+---
+
+## E) Boot Up Target System
+- Insert USB into target PC
+- Power on
+- Enter boot menu (F12 / ESC / DEL depending on vendor)
+- Confirm BIOS/UEFI setting has USB Drive as the first boot priority. (Varies among vendors)
+- Confirm Secure Boot setting is Disabled
+- Save BIOS settings to reboot target system.
+- WinPE will automatically launch the "startnet.cmd" script we edited earlier in the "winpe.wim" image.
+- The script will call "wpeinit", then our "CrashDetectOsReinstall.cmd" script to begin automatic OS crash detection and reimage for WDK driver testing.
+
+---
+
+## F) OPTIONAL: Install OS on new Target System
+### On the bootable USB's second partition `WinPE_USB`
+- Create the folder **`Logs`**.
+- Create an empty file **`InstallOs.flg`** in that folder.
+ - (In File Explorer, ensure file name extensions are visible, else the filename may be accidentally set to `InstallOs.flg.txt`)
+- Plug USB into target system and reboot into USB.
+- The USB will detect the flag and begin reinstalling the OS immediately.
+ - **WARNING**: There will be **NO** prompt to reconfirm OS install, be sure to plug into the correct target system.
+ - Do **NOT** leave this USB plugged into the Host Controller when this flag is set, to avoid accidental OS reinstall.
+
+---
+
+## G) OPTIONAL: Add a Custom Script to Windows Setup
+### Setupcomplete.cmd and ErrorHandler.cmd
+- These are custom scripts that run during or after the Windows Setup process. They can be used to install applications or run other tasks by using cscript/wscript scripts.
+- Follow instructions on this website:
+ - (https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup)
+
+---
+
+## Troubleshooting
+### ERROR: Script "Makewinpemedia.cmd" failed to make WinPE USB bootable!
+- If your Host Controller is connected to a secured IT network, the actions in this script may have been blocked.
+- Check to see if **"bootsect.exe"** was blocked by Windows Security.
+ - Run "Windows Security"
+ - Select "Virus & threat protection"
+ - Click link "Manage ransomware protection" at the bottom
+ - Click link "Allow an app through Controlled folder access"
+ - Click button "Add an allowed app" button, then select option "Recently blocked apps"
+ - Scroll down and look for the "bootsect.exe" app to add to allow list
+### USB won't boot
+- Check BIOS boot order
+- Disable Secure Boot
+### Disk not visible in WinPE
+- Missing storage drivers
+### Windows doesn't boot
+- Re-run `bcdboot`
+- Verify partition layout
+
+---
+
+## Reference Documentation
+- [WinPE overview](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-intro)
+- [Create a USB drive with WinPE and data partitions](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe--use-a-single-usb-key-for-winpe-and-a-wim-file---wim#create-a-usb-drive-with-winpe-and-data-partitions)
+- [WinPE: Create bootable media](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive)
+- [Capture and apply Windows (WIM)](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/capture-and-apply-windows-using-a-single-wim)
+- [Answer files (unattend.xml)](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/update-windows-settings-and-scripts-create-your-own-answer-file-sxs) \ No newline at end of file
diff --git a/.github/crashdetect/Unattend.xml b/.github/crashdetect/Unattend.xml
new file mode 100644
index 00000000..a235fba0
--- /dev/null
+++ b/.github/crashdetect/Unattend.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<unattend xmlns="urn:schemas-microsoft-com:unattend"
+ xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <settings pass="oobeSystem">
+ <component name="Microsoft-Windows-International-Core"
+ processorArchitecture="amd64"
+ publicKeyToken="31bf3856ad364e35"
+ language="neutral"
+ versionScope="nonSxS">
+ <InputLocale>en-US</InputLocale>
+ <SystemLocale>en-US</SystemLocale>
+ <UILanguage>en-US</UILanguage>
+ <UserLocale>en-US</UserLocale>
+ </component>
+
+ <component name="Microsoft-Windows-Shell-Setup"
+ processorArchitecture="amd64"
+ publicKeyToken="31bf3856ad364e35"
+ language="neutral"
+ versionScope="nonSxS">
+
+ <TimeZone>Pacific Standard Time</TimeZone>
+
+ <!-- Skip all OOBE -->
+ <OOBE>
+ <HideEULAPage>true</HideEULAPage>
+ <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
+ <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
+ <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
+ <HideLocalAccountScreen>true</HideLocalAccountScreen>
+ <NetworkLocation>Work</NetworkLocation>
+ <ProtectYourPC>3</ProtectYourPC>
+ </OOBE>
+
+ <UserAccounts>
+ <LocalAccounts>
+ <LocalAccount wcm:action="add">
+ <Name>admin</Name>
+ <Group>Administrators</Group>
+ <Password>
+ <Value>@Password123</Value>
+ <PlainText>true</PlainText>
+ </Password>
+ </LocalAccount>
+ </LocalAccounts>
+ </UserAccounts>
+
+ <!-- Auto logon (lab only) -->
+ <AutoLogon>
+ <Username>admin</Username>
+ <Enabled>true</Enabled>
+ <Password>
+ <Value>@Password123</Value>
+ <PlainText>true</PlainText>
+ </Password>
+ <LogonCount>999</LogonCount>
+ </AutoLogon>
+
+ </component>
+ </settings>
+
+</unattend> \ No newline at end of file
diff --git a/.github/pdu/Pdu.ps1 b/.github/pdu/Pdu.ps1
new file mode 100644
index 00000000..b87fd470
--- /dev/null
+++ b/.github/pdu/Pdu.ps1
@@ -0,0 +1,250 @@
+# ======================================================================
+#
+# Manufacturer: Eaton Tripp Lite Switched Power Distribution Unit (PDU)
+# Website: https://www.eaton.com/us/en-us/skuPage.PDUMH15NET.html
+# Model: PDUMH15NET
+# SNMP/Web Management Accessory Card: WEBCARDLX
+#
+# HW Requirements: Ethernet cable or USBA-to-MicroUSB cable.
+# SW Requirements: Plink.exe from PuTTY terminal client SW (if Ethernet)
+# PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
+#
+# Script: PowerShell script for turning ON/OFF and power CYCLING the PDU
+# Usage: .\Pdu.ps1 [on | off | cycle] [1-16]
+#
+# ======================================================================
+
+param(
+ [Parameter(Mandatory=$true, Position=0)]
+ [ValidateSet("cycle","on","off")]
+ [string]$Action,
+
+ [Parameter(Mandatory=$true, Position=1)]
+ [ValidateRange(1,16)]
+ [int]$LoadNumber
+)
+
+# =========================
+# Configuration
+# =========================
+$ComNumber = 3
+$ComPort = "COM$ComNumber"
+
+$PduIP = "169.254.0.1"
+$SshPort = 22
+
+$Username = "localadmin"
+$Password = "@Password123"
+
+$Plink = "C:\Program Files\PuTTY\plink.exe"
+
+# =========================
+# Helper Functions
+# =========================
+
+function Test-PduSerialConnection
+{
+ [bool]$Connected = $false
+
+ try
+ {
+ $Port = New-Object System.IO.Ports.SerialPort $ComPort,115200,None,8,one
+ $Port.ReadTimeout = 3000
+ $Port.WriteTimeout = 3000
+ $Port.Open()
+ Start-Sleep 5
+ $Port.DiscardOutBuffer()
+ $Port.DiscardInBuffer()
+ $null = $Port.ReadExisting()
+
+ # Wake up console
+ $Port.WriteLine("")
+ Start-Sleep 2
+
+ $Banner = $Port.ReadExisting()
+ if ($Banner -match "login|localadmin|PowerAlert|Ubuntu") {
+ Write-Host "PDU detected on serial connection at $ComPort"
+ $Connected = $true
+ } else {
+ Write-Host "PDU NOT detected on serial connection at $ComPort" -ForegroundColor Yellow
+ }
+ }
+ catch
+ {
+ Write-Host "Unable to communicate on serial connection at $ComPort" -ForegroundColor Yellow
+ Write-Host $_.Exception.Message
+ }
+ finally
+ {
+ if ($Port -and $Port.IsOpen) {
+ $Port.DiscardOutBuffer()
+ $Port.DiscardInBuffer()
+ if ($Port.BytesToRead -gt 0) {
+ $null = $Port.ReadExisting()
+ }
+ $Port.Close()
+ }
+
+ $Port.Dispose()
+ $Port = $null
+ }
+ return $Connected
+}
+
+function Send-PduSerialCommand
+{
+ param([string]$Action)
+
+ $Port = New-Object System.IO.Ports.SerialPort $ComPort,115200,None,8,one
+
+ try
+ {
+ $Port.ReadTimeout = 3000
+ $Port.WriteTimeout = 3000
+
+ $Port.Open()
+ Start-Sleep 5
+ $Port.DiscardOutBuffer()
+ $Port.DiscardInBuffer()
+ $null = $Port.ReadExisting()
+
+ Write-Host "Using SERIAL connection..." -ForegroundColor Green
+ $Port.WriteLine("")
+ Start-Sleep 2
+
+ Write-Host "Sending Username to PDU..."
+ $Port.WriteLine($Username)
+ Start-Sleep 2
+
+ Write-Host "Sending Password to PDU..."
+ $Port.WriteLine($Password)
+ Start-Sleep 5
+
+ # Sending [ cycle | on | off ] command to PDU.
+ Write-Host "Sending '$Action' command to PDU..."
+ $Port.WriteLine("device; load $LoadNumber; $Action force")
+ Start-Sleep 2
+
+ # "Sending Exit command to PDU..."
+ $Port.WriteLine("exit; exit; exit")
+ Start-Sleep 2
+ }
+ catch
+ {
+ Write-Host "Unable to communicate with $ComPort"
+ Write-Host $_.Exception.Message
+ }
+ finally
+ {
+ if ($Port -and $Port.IsOpen) {
+ $Port.DiscardOutBuffer()
+ $Port.DiscardInBuffer()
+ if ($Port.BytesToRead -gt 0) {
+ $null = $Port.ReadExisting()
+ }
+ $Port.Close()
+ Write-Host "Closed serial port $ComPort"
+ }
+ if ($Port)
+ {
+ $Port.Dispose()
+ }
+ $Port = $null
+ }
+}
+
+function Test-PduNetworkConnection
+{
+ [bool]$Connected = $false
+
+ try
+ {
+ $Client = New-Object System.Net.Sockets.TcpClient
+# $Client.Connect($PduIP,$SshPort)
+
+ $Result = $Client.BeginConnect($PduIP,$SshPort,$null,$null)
+ if (-not $Result.AsyncWaitHandle.WaitOne(3000))
+ {
+ throw "Connection timeout"
+ }
+ $Client.EndConnect($Result)
+
+ $Stream = $Client.GetStream()
+ Start-Sleep 1
+
+ $Buffer = New-Object byte[] 1024
+ $Stream.ReadTimeout = 3000
+ $Bytes = $Stream.Read($Buffer,0,$Buffer.Length)
+
+ $Banner = [System.Text.Encoding]::ASCII.GetString($Buffer,0,$Bytes)
+
+ if ($Banner -match "login|localadmin|PowerAlert|Ubuntu") {
+ Write-Host "PDU detected on network connection at IP: $PduIP, Port: $SshPort"
+ $Connected = $true
+ }
+ else {
+ Write-Host "PDU NOT detected on network connection at IP: $PduIP, Port: $SshPort" -ForegroundColor Yellow
+ }
+
+ $Client.Close()
+ }
+ catch
+ {
+ Write-Host "Unable to establish network connection at IP: $PduIP, Port: $SshPort" -ForegroundColor Yellow
+ Write-Host $_.Exception.Message
+ }
+ return $Connected
+}
+
+function Send-PduNetworkCommand
+{
+ param([string]$Action)
+
+ if (-not (Test-Path $Plink))
+ {
+ throw "plink.exe not found: $Plink"
+ }
+
+ Write-Host "Using NETWORK connection..." -ForegroundColor Green
+
+ $Command = "device; load $LoadNumber; $Action force; exit; exit; exit"
+
+ $Command | & $Plink `
+ -ssh `
+ -batch `
+ -pw $Password `
+ "$Username@$PduIP" `
+}
+
+# =========================
+# Main Logic
+# =========================
+
+Write-Host ""
+Write-Host "Requested Action : $Action"
+Write-Host ""
+
+# First choice = Serial
+if (Test-PduSerialConnection)
+{
+ Send-PduSerialCommand $Action
+ exit 0
+}
+
+Write-Host "Serial connection not available."
+Write-Host "Trying network connection..."
+
+# Second choice = Network
+if (Test-PduNetworkConnection)
+{
+ Send-PduNetworkCommand $Action
+ exit 0
+}
+
+Write-Host ""
+Write-Host "ERROR: No PDU connection available." -ForegroundColor Red
+Write-Host " Serial : $ComPort"
+Write-Host " Ethernet : $PduIP"
+Write-Host ""
+
+exit 1 \ No newline at end of file
diff --git a/.github/pdu/PduReadme.md b/.github/pdu/PduReadme.md
new file mode 100644
index 00000000..524bddd2
--- /dev/null
+++ b/.github/pdu/PduReadme.md
@@ -0,0 +1,65 @@
+# PDU Setup: <br>Eaton Tripp Lite Switched Power Distribution Unit (PDUMH15NET)
+
+## Requirements:
+### HW:
+ - USBA-to-MicroUSB cable, needed for 1st time PDU login and password change, if IP address is unknown.
+ - Ethernet cable, can be used if the IP address is known.
+### SW:
+ - [Tera Term 5.6.1 terminal client:](https://github.com/TeraTermProject/teraterm/releases/tag/v5.6.1)
+ - Terminal client for PDU login and configuration via serial.
+ - [PuTTY 0.84 terminal client:](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)
+ - `Plink.exe` needed for PowerShell scripting via network.
+ - **Note**: PuTTY terminal client GUI does not appear to work, so Tera Term client was used instead, but `Plink.exe` is needed for passing passwords via SSH in PowerShell scripts.
+
+## Serial Connection
+### What's my IP address?
+- If the PDU is connected to a network with **DHCP**, then we need to find it's IP address first by using serial connection.
+ - If the PDU is not connected to a network with DHCP, then its default static IP address should be `169.254.0.1`.
+ - If that's the case, then you can login to the PDU via a browser by skipping the the section Network Connection.
+
+Tera Term:
+- Connect the PC to the PDU (CONFIG port) with a USBA-to-MiniUSB cable.
+- On the PC, go to Device Manager and verify under `Ports (COM & LPT)`, the `USB Serial Device (COM3)` device is present.
+- Download and install Tera Term on PC, if not already present.
+ - You may use other Terminal Emulation Programs, but this is the one used in the manufacturer's user manual to connect to the WEBCARDLX network interface card.
+- Launch Tera Term and select the "Serial" connection type and ensure `Port: "COM3: USB Serial Device (COM3)` is selected, then click "OK".
+- When the blinking cursor in the empty prompt stops blinking, hit Enter key to wake up console.
+- The `Ubuntu 18.04.6 LTS poweralert-0006674a215f` (<-- MAC Address) should show up in the prompt asking for login.
+ - Default login is: `localadmin`
+ - Default 1st time password is: `localadmin`
+ - Must change password after 1st logon.
+ - Change password to `@Password123` to match what the `pdu.ps1` PowerShell script uses.
+- Once logged in, type `show network` to display network information such as current IP address.
+ - If on DHCP network, note the IP address assigned to the PDU.
+ - PDU default if no DHCP:
+ - IPv4: `169.254.0.1`
+ - Subnet Mask: `255.255.0.0`
+- Test pinging the IPv4 address of the PDU from the PC.
+ - `ping <IP Address>`
+- Now that you have the IP address, it may be easier to switch over to the browser interface to configure the rest of the PDU.
+
+## Network Connection
+- Connect an Ethernet cable from the PC to the PDU Ethernet port.
+- Since we have the IP of the PDU, it's easier to configure the PDU via a browser interface.
+- Open an Internet browser and enter the IPv4 address of the PDU into the browser.
+ - If it prompts you about any security warnings, just find a way to accept and continue anyway.
+- The `Power Alert LX` web interface should prompt for username and password.
+- If 1st time login...
+ - Default login is: `localadmin`
+ - Default 1st time password is: `localadmin`
+ - Must change password after 1st logon.
+ - Change password to `@Password123` to match what the `pdu.ps1` PowerShell script uses.
+- Select `Load` tab on the left of screen to see all the loads on the 16 power ports.
+- Click on the `State` slider to show the Load options, `Turn Off Load` and `Cycle Load`.
+- To enable SSH for PowerShell scripting later, select `Network` tab, then `Services`, then enable `SSH Enabled`.
+
+## Scripting
+- The `Pdu.ps1` PowerShell script can be used for automating power ON/OFF/CYCLE of the PDU ports.
+- Usage: `.\Pdu.ps1 [on | off | cycle] [1-16]`
+- Update the following variables in the `Pdu.ps1` script if necessary.
+ - `$PduIP = "169.254.0.1"`
+ - `$Password = "@Password123"`
+- The script will check first if there's a serial connection first, then network connection if serial is not present, before issuing the PDU command.
+
+## References
+- Eaton Tripp Lite Switched PDU (PDUMH15NET): [Manuals & User Guides](https://www.eaton.com/us/en-us/skuPage.PDUMH15NET.html#tab-2) \ No newline at end of file