Windows Server 2012r2 Iso 〈Verified ✪〉

$UnattendContent += @" </FirstLogonCommands> <OOBE> <HideEULAPage>true</HideEULAPage> <NetworkLocation>Work</NetworkLocation> <ProtectYourPC>3</ProtectYourPC> <SkipMachineOOBE>true</SkipMachineOOBE> <SkipUserOOBE>true</SkipUserOOBE> </OOBE> </component> </settings> </unattend> "@ $UnattendPath = "$ExtractDir\unattend.xml" $UnattendContent | Out-File -FilePath $UnattendPath -Encoding UTF8 Copy to mount (for boot.wim as well) $BootWimPath = "$ExtractDir\sources\boot.wim" $BootMountDir = "$WorkDir\boot_mount" New-Item $BootMountDir -ItemType Directory -Force | Out-Null

if (-not (Test-Path $OscdimgPath)) Write-Host "oscdimg.exe not found. Downloading alternative..." -ForegroundColor Yellow # Alternative: Use mkisofs from cdrtools Write-Host "Please install Windows ADK: https://go.microsoft.com/fwlink/?linkid=2165885" -ForegroundColor Red exit 1

# ====================================================== # Windows Server 2012 R2 Custom ISO Builder # Features: Unattended install, driver injection, updates # Requires: Windows ADK, oscdimg.exe, admin rights # ====================================================== param( [Parameter(Mandatory=$true)] [string]$SourceISOPath, # Original Windows Server 2012 R2 ISO windows server 2012r2 iso

[string]$UpdatesFolder, # Folder with .msu updates (optional) [string]$DriversFolder, # Folder with .inf drivers (optional) [string]$PostInstallScript, # PowerShell script to run after setup (optional) [string]$ProductKey, # Product key for unattended install (optional) [string]$AdminPassword # Local admin password (optional) ) $ErrorActionPreference = "Stop" Check admin rights if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) Write-Host "Please run as Administrator" -ForegroundColor Red exit 1 Create working directory $WorkDir = "C:\WindowsServerISO_Build" $MountDir = "$WorkDir\mount" $ExtractDir = "$WorkDir\extract" $TempDir = "$WorkDir\temp"

$BootFile = "$ExtractDir\boot\etfsboot.com" & $OscdimgPath -bootdata:2#p0,e,b$BootFile -u2 -udfver102 $ExtractDir $OutputISOPath Write-Host "`nCleaning up temporary files..." -ForegroundColor Gray Remove-Item $WorkDir -Recurse -Force $UnattendContent += @" &lt

[Parameter(Mandatory=$true)] [string]$OutputISOPath, # Custom ISO output path

dism /Mount-Image /ImageFile:$BootWimPath /Index:1 /MountDir:$BootMountDir Copy-Item $UnattendPath "$BootMountDir" -Force dism /Unmount-Image /MountDir:$BootMountDir /Commit Remove-Item $BootMountDir -Recurse -Force Write-Host "[6/7] Committing changes to WIM..." -ForegroundColor Yellow dism /Unmount-Image /MountDir:$MountDir /Commit Step 7: Create new ISO Write-Host "[7/7] Creating custom ISO..." -ForegroundColor Yellow Check for oscdimg.exe (part of Windows ADK) $OscdimgPath = "$env:ProgramFiles(x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe" updates # Requires: Windows ADK

else Write-Host "[4/7] Skipping updates" -ForegroundColor Gray Write-Host "[5/7] Creating unattended installation file..." -ForegroundColor Yellow