/Windows_PE

Automatic build & customization of WinPE

Primary LanguagePowerShell

Windows_PE

Create WinPE_amd64.iso Donate Buy Me A Coffee

Automatic build & customization of WinPE

Basic

  • New-WinPE
  • New-FolderStructure
    • change bloated structure to MDT-based structure
      • Remove root language folders and sources
      • Add MDT-structure and move boot.wim to Deploy\Boot
  • Mount-WinPE
  • Add-FilesToWinPE
    • Loop over contents source\_winpe
  • Add-AppsToWinPE
    • Download applications (portable) and installs to target path
  • Add-OptionalComponents
  • Add-BootDrivers
    • none, all, hp, dell, lenovo, vmware
    • Release will contain 'all'
  • Add-Updates
    • Disabled
  • Invoke-WinPEcleanup
    • Disabled
  • Get-HashOfContents
    • Disabled due to permsssion issue in boot.wim system files
  • Dismount-Image
  • Add-FilesToIso
    • Loop over contents source\_iso
  • Set-BCDData
    • Required due to folder structure change
  • New-ISO

Screenshot after <15sec boot:

image

Customization

Basic commands

  • Mount
    Mount-WindowsImage -ImagePath "$ISO_root\Deploy\Boot\boot.wim" -index 1 -Path "$WinPE_root"
  • Unmount
    Dismount-WindowsImage -Path "$WinPE_root" -Save
  • ToISO
    makeWinPEMedia.cmd /ISO $workingDirectory\WinPE_$arch workingDirectory\WinPE_$arch.iso

Drivers

  • Add-WindowsDriver -Path "$WinPE_root" -Driver ".\source\Drivers\$branding" -verbose -Recurse"

Applications

  • Launchbar
    • Quicklaunch for apps
  • DeploymentMonitoringTool.exe (included in source)
    • Get info about current machine
  • CMTrace_amd64.exe (included in source)
    • Read MDT and other logs
  • Process Explorer
  • 7-Zip
  • Powershell 7.2.2+
  • Notepad++
  • DoubleCMD
    • File Explorer as Explorer.exe is unavailable
  • Missing executables and added:
    • label
    • logman
    • runas
    • sort
    • tzutil
    • Utilman
    • clip
    • eventcreate
    • forfiles
    • setx
    • timeout
    • waitfor
    • where
    • whoami.exe

Files

  • WinPE (X:)
    • Add to $workingDirectory\WinPE_$arch\mount folder.
    • Included files in source\_winpe\Windows\System32 to be added to $workingDirectory\WinPE_$arch\mount\Windows\System32
      • CMTrace_amd64.exe
      • DeploymentMonitoringTool.exe
      • LaunchBar_x64.exe
      • launchbar.ini
      • test.bat
      • winpeshl.ini
  • ISO
    • Add to "$workingDirectory\WinPE_$arch\media" folder

Enabled components

Click to show
  • WinPE-HTA
  • WinPE-WMI
  • WinPE-NetFX
  • WinPE-Scripting
  • WinPE-SecureStartup
  • WinPE-PlatformID
  • WinPE-PowerShell
  • WinPE-DismCmdlets
  • WinPE-SecureBootCmdlets
  • WinPE-StorageWMI
  • WinPE-EnhancedStorage
  • WinPE-Dot3Svc
  • WinPE-FMAPI
  • WinPE-FontSupport-WinRE
  • WinPE-PlatformId
  • WinPE-WDS-Tools
  • WinPE-WinReCfg

Inactive Components

Click to show
  • WinPE-Fonts-Legacy
  • WinPE-Font Support-JA-JP
  • WinPE-Font Support-KO-KR
  • WinPE-Font Support-ZH-CN
  • WinPE-Font Support-ZH-HK
  • WinPE-GamingPeripherals
  • Winpe-LegacySetup
  • WinPE-MDAC
  • WinPE-PPPoE
  • WinPE-Rejuv
  • WinPE-RNDIS
  • WinPE-Setup
  • WinPE-Setup-Client
  • WinPE-Setup-Server
  • WinPE-SRT
  • WinPE-WiFi-Package

Documentation

Full Windows UEFI Boot schematic of Windows PE

%%{init: {'theme': 'dark', 'themeVariables': { 'darkMode': 'true'}}}%%


flowchart TB
    WR[Winlogon.exe reads HKLM\System\Setup\CmdLine:<br> winpeshl.exe]
    WP[winpeshl.exe runs]
    SE{%SYSTEMDRIVE%\sources\setup.exe exist?}
    RE[Run Setup.exe]
    RW[Read winpeshl.ini]
    AP{Winpeshl.ini exist and has valid content?}

    A1[Run App1.exe with parameter /parameter1]


    MD{MDT is included?}
    RS[Run <br>cmd /k %SYSTEMROOT\system32\startnet.cmd]
    SN[Startnet.cmd: <br>wpeinit.exe]

    RA[Run applications as specified in winpeshl.ini<br><br><i>Run app in order of appearance <br>Starts when the previous app has terminated.</i>]

    UE{Unattend.xml exist?}
    UX[Unattend.xml:<br>RunSynchronousCommand<br> wscript.exe X:\Deploy\Scripts\LiteTouch.wsf]
    WI[wpeinit.exe]
    BD[bddrun.exe]
    LT[LiteTouch.wsf]
    LP{Check if there are any Task Sequences in progress <br>c:\minint and/or <br>c:\_SMSTaskSequence\TSEnv.dat}
    ET[Execute Task Sequence]
    NT[New Task Sequence]
    BS[Bootstrap.ini]
    CS[CustomSettings.ini from DeployRoot]
    WW[Welcome Wizard]
    DW[Deployment Wizard]
    RT[Run Task Sequence]

    PO[POST]
    LF[Launch UEFI Firmware]
    BI[Get Boot Info from SRAM]
    LB[Launch Windows Boot Manager]
    BM[EFI-BOOT-BOOTX64]
    RB[Read BCD-file]
    WL[Launch Boot Loader<br>Boot.wim:<br>Winload.efi]
    LO[Load HAL, Registry, Boot Drivers]
    NL[Ntoskrnl.exe]
    SM[SMSS.exe]
    W3[Win32k.sys]
    WN[Winlogon.exe]



subgraph UEFI [UEFI Boot]
    PO ==> LF
    LF ==> BI
    BI ==> LB
    subgraph WBM [Windows Boot Manager]
        LB ==> BM
        BM ==> RB
    end
    RB ==> WL
    subgraph WBL [Windows Boot Loader]
        WL ==> LO
    end
    subgraph KRN [Windows NT OS Kernel]
        LO ==> NL
        NL ==> SM
        SM -.-> W3
        SM ==> WN
    end

end
WN==> WR
subgraph WinPE
    WR ==> WP ==> SE
    SE ==> |yes| RE
    SE ==> |no | RW
    RW ==> AP
    AP ==> |yes| RA

    MD ==> |yes| BD
    MD ==> |no| Error
    RA ==>| %SYSTEMDRIVE%\Apps\App1.exe, /parameter1 | A1
    RA ==>| %SYSTEMROOT%\System32\bddrun.exe, /bootstrap | MD
    AP ==> |no | RS



subgraph cmd [cmd.exe]
    RS ==> SN
end

    
subgraph MDT [MDT]
    SN -.-> WI
    BD ==> WI
    WI -.-> UE
    UE ==> |yes| UX
    UX ==> LT ==> LP
    LP ==> |no| NT
    LP ==> |yes| ET
    NT ==> |ZTIGather| BS
    BS ==> WW
    WW ==> CS
    CS ==> DW
    DW ==> RT
    RT ==> ET
end

end
UX -...- |ERROR| cmd