@@ -727,15 +727,41 @@ Write-Host "Copying unattended file for bypassing MS account on OOBE..."
727727Copy-Item - Path " $PSScriptRoot \autounattend.xml" - Destination " $mainOSDrive \tiny11\autounattend.xml" - Force > null
728728
729729Write-Host " Creating ISO image..."
730+ # Define the path to the ADK Deployment Tools folder
730731$ADKDepTools = " C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture \Oscdimg"
732+ $localOSCDIMGPath = " $PSScriptRoot \oscdimg.exe"
733+
734+ # Check if the ADK Deployment Tools folder exists
731735if ([System.IO.Directory ]::Exists($ADKDepTools )) {
732736 Write-Host " Will be using oscdimg.exe from system ADK."
733737 $OSCDIMG = " $ADKDepTools \oscdimg.exe"
734738} else {
735- Write-Host " Will be using bundled oscdimg.exe."
736- $OSCDIMG = " $PSScriptRoot \oscdimg.exe"
739+ Write-Host " ADK folder not found. Will be using bundled oscdimg.exe."
740+
741+ # Define the URL of the file to be downloaded
742+ $url = " https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe"
743+
744+ # Download oscdimg.exe if it doesn't exist in the script's directory
745+ if (-not (Test-Path - Path $localOSCDIMGPath )) {
746+ Write-Host " Downloading oscdimg.exe..."
747+ Invoke-WebRequest - Uri $url - OutFile $localOSCDIMGPath
748+
749+ # Check if the download was successful
750+ if (Test-Path $localOSCDIMGPath ) {
751+ Write-Host " oscdimg.exe downloaded successfully."
752+ } else {
753+ Write-Error " Failed to download oscdimg.exe."
754+ exit 1
755+ }
756+ } else {
757+ Write-Host " oscdimg.exe already exists locally."
758+ }
759+
760+ $OSCDIMG = $localOSCDIMGPath
737761}
738- & " $OSCDIMG " ' -m' ' -o' ' -u2' ' -udfver102' " -bootdata:2#p0,e,b$mainOSDrive \tiny11\boot\etfsboot.com#pEF,e,b$mainOSDrive \tiny11\efi\microsoft\boot\efisys.bin" " $mainOSDrive \tiny11" " $PSScriptRoot \tiny11.iso"
762+
763+ # Execute oscdimg.exe with the specified parameters
764+ & " $OSCDIMG " ' -m' ' -o' ' -u2' ' -udfver102' " -bootdata:2#p0,e,b$ScratchDisk \tiny11\boot\etfsboot.com#pEF,e,b$ScratchDisk \tiny11\efi\microsoft\boot\efisys.bin" " $ScratchDisk \tiny11" " $PSScriptRoot \tiny11.iso"
739765
740766# Finishing up
741767Write-Host " Creation completed! Press any key to exit the script..."
0 commit comments