- For the current session
- Download Windows 11 ISO
- Create temporary folders
- Copy ISO to folder
- Extract install.wim from ISO
- Unpack all Intel Rapid Storage drivers in C:\mount\drivers
- Optimizing the image
- Unmount the WinRE image
- Optimizing the image, part 2
- Unmount the Windows image
- Mount recovery partition using DISKPART
- Create a new directory in the Wndows RE Tools partitions
- Register your custom Windows RE tools image
Set-ExecutionPolicy "Unrestricted"
New-Item -Path "c:\mount\windows" -ItemType "directory" -Force
New-Item -Path "c:\mount\winre" -ItemType "directory" -Force
Copy-Item "$Env:USERPROFILE\Downloads\Win11_22H2_English_x64v1.iso" -Destination "C:\mount"
Copy-Item "D:\sources\install.wim" -Destination "C:\mount"
Get-ChildItem -Recurse -Path "C:\mount\drivers\15063\Drivers" -Filter *.inf | ForEach-Object {
Dism /Image:C:\mount\winre /Add-Driver /Driver:"$_"
}
Dism /Image:c:\mount\winre /Cleanup-Image /StartComponentCleanup
Dism /Unmount-Image /MountDir:C:\mount\winre /Commit
Dism /Export-Image /SourceImageFile:c:\mount\windows\windows\system32\recovery\winre.wim /SourceIndex:1 /DestinationImageFile:c:\mount\winre-optimized.wim
Remove-Item c:\mount\windows\windows\system32\recovery\winre.wim
Copy-Item "c:\mount\winre-optimized.wim" -Destination "c:\mount\windows\windows\system32\recovery\winre.wim"
Copy-Item "c:\mount\windows\Windows\System32\Recovery\winre.wim" -Destination "c:\Windows\system32\Recovery\"
Dism /Unmount-Image /MountDir:C:\mount\windows /Commit
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 953 GB 1024 KB *
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 System 100 MB 1024 KB
Partition 2 Reserved 16 MB 101 MB
Partition 3 Primary 953 GB 117 MB
Partition 4 Recovery 625 MB 953 GB
DISKPART> select partition=4
Partition 4 is now the selected partition.
DISKPART> assign letter=R
DiskPart successfully assigned the drive letter or mount point.
DISKPART> exit
Leaving DiskPart...
New-Item -Path "r:\Recovery\WindowsRE" -ItemType "directory" -Force
Copy-Item "c:\mount\windows\windows\system32\recovery\winre.wim" -Destination "r:\Recovery\WindowsRE"
c:\Windows\System32\Reagentc /setreimage /path r:\Recovery\WindowsRE /target c:\Windows
c:\Windows\System32\Reagentc /info