Windows Server 2012r2 Iso [patched] Info

$UnattendContent = @" <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="windowsPE"> <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <DiskConfiguration> <WillShowUI>OnError</WillShowUI> <Disk> <DiskID>0</DiskID> <WillWipeDisk>true</WillWipeDisk> <CreatePartitions> <CreatePartition> <Order>1</Order> <Type>Primary</Type> <Size>500</Size> </CreatePartition> <CreatePartition> <Order>2</Order> <Type>Primary</Type> <Extend>true</Extend> </CreatePartition> </CreatePartitions> <ModifyPartitions> <ModifyPartition> <Order>1</Order> <PartitionID>1</PartitionID> <Format>NTFS</Format> <Label>System Reserved</Label> <Active>true</Active> </ModifyPartition> <ModifyPartition> <Order>2</Order> <PartitionID>2</PartitionID> <Format>NTFS</Format> <Label>OS</Label> </ModifyPartition> </ModifyPartitions> </Disk> </DiskConfiguration> <ImageInstall> <OSImage> <InstallTo> <DiskID>0</DiskID> <PartitionID>2</PartitionID> </InstallTo> </OSImage> </ImageInstall> <UserData> <AcceptEula>true</AcceptEula> <ProductKey> <Key>$ProductKey</Key> </ProductKey> </UserData> </component> </settings> <settings pass="specialize"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <ComputerName>WIN-SERVER-2012R2</ComputerName> <RegisteredOwner>IT Admin</RegisteredOwner> <RegisteredOrganization>Company</RegisteredOrganization> <TimeZone>Pacific Standard Time</TimeZone> </component> <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> </component> </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <AutoLogon> <Password> <Value>$AdminPassword</Value> <PlainText>true</PlainText> </Password> <Enabled>true</Enabled> <LogonCount>1</LogonCount> <Username>Administrator</Username> </AutoLogon> <FirstLogonCommands> <SynchronousCommand> <Order>1</Order> <CommandLine>cmd /c winrm quickconfig -quiet</CommandLine> <Description>Enable WinRM</Description> </SynchronousCommand> <SynchronousCommand> <Order>2</Order> <CommandLine>powershell -Command "Set-ExecutionPolicy RemoteSigned -Force"</CommandLine> <Description>Set Execution Policy</Description> </SynchronousCommand> <SynchronousCommand> <Order>3</Order> <CommandLine>powershell -Command "Enable-PSRemoting -Force"</CommandLine> <Description>Enable PSRemoting</Description> </SynchronousCommand> "@ if ($PostInstallScript -and (Test-Path $PostInstallScript)) $ScriptContent = Get-Content $PostInstallScript -Raw $EncodedScript = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($ScriptContent)) $UnattendContent += @" <SynchronousCommand> <Order>4</Order> <CommandLine>powershell -EncodedCommand "$EncodedScript"</CommandLine> <Description>Run Post-Install Script</Description> </SynchronousCommand> "@

Write-Host " n========================================" -ForegroundColor Cyan Write-Host "Windows Server 2012 R2 Custom ISO Builder" -ForegroundColor Cyan Write-Host "======================================== n" -ForegroundColor Cyan Write-Host "[1/7] Extracting source ISO..." -ForegroundColor Yellow Mount-DiskImage -ImagePath $SourceISOPath -PassThru | ForEach-Object Get-Volume).DriveLetter + ":" Copy-Item "$DriveLetter*" -Destination $ExtractDir -Recurse -Force Dismount-DiskImage -ImagePath $SourceISOPath Step 2: Mount WIM image (Server Standard + GUI) Write-Host "[2/7] Mounting Windows image..." -ForegroundColor Yellow $WimPath = "$ExtractDir\sources\install.wim" $Index = 2 # Index 2 = Windows Server 2012 R2 Standard (Server with GUI)

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" windows server 2012r2 iso

@($WorkDir, $MountDir, $ExtractDir, $TempDir) | ForEach-Object Out-Null

# ====================================================== # 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 $UnattendContent = @" &lt;

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

[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" $UnattendContent = @" &lt

$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