Image Automatically without using USB or network boot


  • Is it possible to image automatically without using a USB or PXE?

    For example select a group (for example a lab) and push a new image to them. It can avoid manual work of going to individual devices to boot from a USB to re-image.

    1. Copy the boot file to a folder in C:\ drive
      2. Boot into windows PE using ramdisk

    https://learn.microsoft.com/en-us/answers/questions/563319/setup-bcd-to-boot-pe-from-ram.html


  • If somebody is looking at a similar solution, you can use PowerShell to do this. This is not my script, but it works perfectly.

    <#
    
    .Synopsis
        This script will create a ramdisk containing the boot.wim which the computer will boot to on restart. This script will work only on Windows Imaging environment.
    
    .Prerequisites
        - From the Windows PE boot USB, copy boot.wim in the Sources folder to C:\Sources on the target
        - From the Windows PE boot USB, copy the Boot folder to C:\ on the target
    
    .Notes
        Because "bcdedit /bootsequence" is used, the computer should boot back into Windows when restarted if imaging is cancelled.
    
    #>
    
    # Checks that Disk 0 is the boot disk.
    $DISKZERO = Get-Disk 0
    If ($DISKZERO.IsBoot -ne $true) {
    Write-Host "Disk 0 is not the boot disk. Exiting..."
    Exit 999
    }
    else {
    Write-Host "Disk 0 is the boot disk. Proceeding..."
    }
    
    # Create {ramdiskoptions} and configure
    bcdedit -create "{ramdiskoptions}"
    bcdedit /set "{ramdiskoptions}" ramdisksdidevice partition=C:
    bcdedit /set "{ramdiskoptions}" ramdisksdipath \boot\boot.sdi
    
    # Add LiteTouch boot device to OSLOADER
    $Output = bcdedit -create /d "LiteTouch MDT" /application OSLOADER
    
    # Obtain LiteTouch boot device GUID
    $LTGUID = $Output | %{ $_.split(' ')[2] }
    
    # Configure LiteTouch to ramdisk boot
    bcdedit /set $LTGUID device "ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}"
    bcdedit /set $LTGUID osdevice "ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}"
    bcdedit /set $LTGUID systemroot \windows
    bcdedit /set $LTGUID detecthal yes
    bcdedit /set $LTGUID winpe yes
    
    # Adjust for UEFI vs Legacy BIOS types
    if ($env:firmware_type -eq 'UEFI'){
    Write-Host "UEFI boot confirmed."
    bcdedit /set $LTGUID path \windows\system32\boot\winload.efi
    }
    Else {
    Write-Host "Legacy boot confirmed."
    bcdedit /set $LTGUID path \windows\system32\boot\winload.exe
    }
    
    # Force LiteTouch ramdisk on next boot and restart
    bcdedit /bootsequence $LTGUID
    shutdown /r /f /t 0