From 7ad5ed602bb50d16279b249c4134fce699b2c427 Mon Sep 17 00:00:00 2001 From: Peter Reichart Date: Wed, 4 Dec 2024 11:13:18 +0000 Subject: [PATCH] Dateien nach "/" hochladen --- builder_0.1_.ps1 | 268 ++++++++++++++++++++++++----------------------- 1 file changed, 137 insertions(+), 131 deletions(-) diff --git a/builder_0.1_.ps1 b/builder_0.1_.ps1 index 0cea628..ba7069b 100644 --- a/builder_0.1_.ps1 +++ b/builder_0.1_.ps1 @@ -1,131 +1,137 @@ -# -# Treiber in ein Windows -# - -# Diese Variablen jeweils anpassen: -# Installationspfad -$droot = "C:\win11_slipstream" -# Name und Ort der Qeull-ISO Datei -$isoFile = "${droot}\Win11_24H2_German_x64.iso" - -# ------------------------------------------------------------------------------- -# Ab hier nichts mehr ändern, außer Du weisst was Du tust! -# ------------------------------------------------------------------------------- -$workPath = "${droot}\mount\work" -$toolPath = "${droot}\tools" -$isoPath = "${droot}\mount\ISO" -$addFiles = "${droot}\addfiles" -$wimPath = "${addFiles}\Sources" - - -function CreateDirs { - New-Item -ItemType Directory -Force -Path "${isoPath}" > $null - New-Item -ItemType Directory -Force -Path "${workPath}" > $null - New-Item -ItemType Directory -Force -Path "${addfiles}" > $null - New-Item -ItemType Directory -Force -Path "${addfiles}\Updates" > $null - New-Item -ItemType Directory -Force -Path "${addfiles}\Sources" > $null - New-Item -ItemType Directory -Force -Path "${wimpath}" > $null - New-Item -ItemType Directory -Force -Path "${droot}\mount\boot" > $null - New-Item -ItemType Directory -Force -Path "${droot}\mount\install" > $null - New-Item -ItemType Directory -Force -Path "${droot}\drivers\boot" > $null - New-Item -ItemType Directory -Force -Path "${droot}\drivers\install" > $null -} -function DiscardMounts { - Write-Host "Lösche eventuelle Mounts" - DISM /Unmount-Wim /MountDir:${droot}\mount\boot /Discard - DISM /Unmount-Wim /MountDir:${droot}\mount\install /Discard -} -function CopyIso { - Write-Host "Es wird die Datei ${isoFile} als Vorlage verwendet!" - # mountet eine Windows .ISO Datei und merkt sich den Laufwerksbuchstaben ----------------------------- - $mountResult = Mount-DiskImage -ImagePath $isoFile -PassThru - $driveLetter = ($mountResult | Get-Volume).DriveLetter - Write-Host "Mounte .ISO Datei nach ${driveLetter}: ..." - - # Kopiert die ISO auf das lokale Laufwerk ------------------------------------------------------------ - Write-Host "Kopiere Inhalt der .ISO ..." - New-Item -ItemType Directory -Force -Path "$isoPath" > $null - Copy-Item -Path "${driveLetter}:\*" -Destination "$isoPath" -Recurse -Force - - if(-not(Test-Path "${wimPath}\boot.wim")) - { - Write-Host "Kopiere boot.wim ..." - cp ${driveLetter}:\sources\boot.wim ${wimPath} - attrib -R ${wimPath}\boot.wim - } else { - Write-Host "boot.wim ist bereits vorhanden und wird übersprungen." - } - if(-not(Test-Path "${wimPath}\install.wim")) - { - Write-Host "Kopiere install.wim..." - cp ${driveLetter}:\sources\install.wim ${wimPath} - attrib -R ${wimPath}\install.wim - } else { - Write-Host "install.wim ist bereits vorhanden und wird übersprungen." - } - - Write-Host "Kopieren abgeschlossen." - - # Trenne .ISO Datei ---------------------------------------------------------------------------------- - Write-Host "Trenne .ISO Datei..." - Dismount-DiskImage -ImagePath $isoFile -} -function ConvertEsd { - # Achtung! Funktion ist unfertig! - Write-Host "Konvertiere install.esd nach install.wim..." - dism /get-wiminfo /wimfile:${droot}\install.esd - dism /export-image /SourceImageFile:${droot}\install.esd /SourceIndex:5 /DestinationImageFile:${droot}\install.wim /Compress:max /CheckIntegrity - attrib -R ${droot}\install.wim -} -function ModifiyBoot { - # füge Treiber in das boot.wim Image ein - Write-Host "Mounte die boot.wim..." - Write-Host "Füge die Treiber unterhalb von drivers\boot in die boot.wim ein..." - #dism /get-wiminfo /wimfile:${wimPath}\boot.wim - DISM /Mount-Wim /WimFile:${wimPath}\boot.wim /Index:1 /MountDir:${droot}\mount\boot - DISM /Image:${droot}\mount\boot /Add-Driver /Driver:${droot}\drivers\boot /recurse /forceunsigned - Write-Host "Trenne boot.wim..." - DISM /Unmount-Wim /MountDir:${droot}\mount\boot /Commit -} -function ModifyInstall { - # füge Treiber und Updates in das install.wim Image ein - Write-Host "Mounte die install.wim..." - Write-Host "Füge die Treiber unterhalb von drivers\install in die install.wim ein..." - #dism /get-wiminfo /wimfile:${addFiles}\Sources\install.wim - DISM /Mount-Wim /WimFile:${addFiles}\Sources\install.wim /Index:1 /MountDir:${droot}\mount\install - DISM /Image:${droot}\mount\install /Add-Driver /Driver:${droot}\drivers\install /recurse /forceunsigned - DISM /Image:${droot}\mount\install /add-package /PackagePath:${droot}\addfiles\updates - Write-Host "Trenne install.wim..." - DISM /Unmount-Wim /MountDir:${droot}\mount\install /Commit -} -function CreateISO { - Write-Host "Erstelle neues Windows-Image ..." - Write-Host " kopiere originale ISO Dateien ..." - cp ${isoPath}\* ${workPath} -Recurse -Force - - Write-Host " kopiere zusäzliche Dateien ..." - cp ${addFiles}\* ${workPath} -Recurse -Force - - Write-Host "Erstelle bootable.iso ..." - # $toolPath\oscdimg.exe -b"${toolPath}\efisys.bin" -udfver102 -u2 -h -m -o ${workPath} ${droot}\bootable.iso - Start-Process -Filepath "$toolPath\oscdimg.exe" -ArgumentList "-b`"${toolPath}\efisys.bin`" -udfver102 -u2 -h -m -o ${workPath} ${droot}\bootable.iso" -} -function CleanUp { - Write-Host "Räume auf..." - # HKLM\SOFTWARE\Microsoft\WIMMount\mounted images\ - DISM /Cleanup-Wim - DISM /Get-MountedImageInfo - DISM /Get-MountedWimInfo -} - -<# - -DiscardMounts -CreateDirs -CopyIso -ModifyBoot -ModifyInstall -CleanUp -CreateISO - -#> +# +# Treiber in ein Windows +# + +# Diese Variablen jeweils anpassen: +# Installationspfad +$droot = "C:\win11_slipstream" +# Name und Ort der Qeull-ISO Datei +$isoFile = "${droot}\Win11_24H2_German_x64.iso" +# Name und Ort der neu zu erstellenden .ISO +$isoOutfile = "c:\public\Win11_24H2_AE-Edition_x64.iso" + +# ------------------------------------------------------------------------------- +# Ab hier nichts mehr ändern, außer Du weisst was Du tust! +# ------------------------------------------------------------------------------- +$workPath = "${droot}\mount\work" +$toolPath = "${droot}\tools" +$isoPath = "${droot}\mount\ISO" +$addFiles = "${droot}\addfiles" +$wimPath = "${addFiles}\Sources" + + +function CreateDirs { + New-Item -ItemType Directory -Force -Path "${isoPath}" > $null + New-Item -ItemType Directory -Force -Path "${workPath}" > $null + New-Item -ItemType Directory -Force -Path "${addfiles}" > $null + New-Item -ItemType Directory -Force -Path "${addfiles}\Updates" > $null + New-Item -ItemType Directory -Force -Path "${addfiles}\Sources" > $null + New-Item -ItemType Directory -Force -Path "${wimpath}" > $null + New-Item -ItemType Directory -Force -Path "${droot}\mount\boot" > $null + New-Item -ItemType Directory -Force -Path "${droot}\mount\install" > $null + New-Item -ItemType Directory -Force -Path "${droot}\drivers\boot" > $null + New-Item -ItemType Directory -Force -Path "${droot}\drivers\install" > $null +} +function DiscardMounts { + Write-Host "Lösche eventuelle Mounts" + DISM /Unmount-Wim /MountDir:${droot}\mount\boot /Discard + DISM /Unmount-Wim /MountDir:${droot}\mount\install /Discard +} +function CopyIso { + Write-Host "Es wird die Datei ${isoFile} als Vorlage verwendet!" + # mountet eine Windows .ISO Datei und merkt sich den Laufwerksbuchstaben ----------------------------- + $mountResult = Mount-DiskImage -ImagePath $isoFile -PassThru + $driveLetter = ($mountResult | Get-Volume).DriveLetter + Write-Host "Mounte .ISO Datei nach ${driveLetter}: ..." + + # Kopiert die ISO auf das lokale Laufwerk ------------------------------------------------------------ + Write-Host "Kopiere Inhalt der .ISO ..." + New-Item -ItemType Directory -Force -Path "$isoPath" > $null + Copy-Item -Path "${driveLetter}:\*" -Destination "$isoPath" -Recurse -Force + + if(-not(Test-Path "${wimPath}\boot.wim")) + { + Write-Host "Kopiere boot.wim ..." + cp ${driveLetter}:\sources\boot.wim ${wimPath} + attrib -R ${wimPath}\boot.wim + } else { + Write-Host "boot.wim ist bereits vorhanden und wird übersprungen." + } + if(-not(Test-Path "${wimPath}\install.wim")) + { + Write-Host "Kopiere install.wim..." + cp ${driveLetter}:\sources\install.wim ${wimPath} + attrib -R ${wimPath}\install.wim + } else { + Write-Host "install.wim ist bereits vorhanden und wird übersprungen." + } + + Write-Host "Kopieren abgeschlossen." + + # Trenne .ISO Datei ---------------------------------------------------------------------------------- + Write-Host "Trenne .ISO Datei..." + Dismount-DiskImage -ImagePath $isoFile +} +function ConvertEsd { + # Achtung! Funktion ist unfertig! + Write-Host "Konvertiere install.esd nach install.wim..." + dism /get-wiminfo /wimfile:${droot}\install.esd + dism /export-image /SourceImageFile:${droot}\install.esd /SourceIndex:5 /DestinationImageFile:${droot}\install.wim /Compress:max /CheckIntegrity + attrib -R ${droot}\install.wim +} +function ModifiyBoot { + # füge Treiber in das boot.wim Image ein + Write-Host "Mounte die boot.wim..." + Write-Host "Füge die Treiber unterhalb von drivers\boot in die boot.wim ein..." + #dism /get-wiminfo /wimfile:${wimPath}\boot.wim + DISM /Mount-Wim /WimFile:${wimPath}\boot.wim /Index:1 /MountDir:${droot}\mount\boot + DISM /Image:${droot}\mount\boot /Add-Driver /Driver:${droot}\drivers\boot /recurse /forceunsigned + Write-Host "Trenne boot.wim..." + DISM /Unmount-Wim /MountDir:${droot}\mount\boot /Commit +} +function ModifyInstall { + # füge Treiber und Updates in das install.wim Image ein + Write-Host "Mounte die install.wim..." + Write-Host "Füge die Treiber unterhalb von drivers\install in die install.wim ein..." + #dism /get-wiminfo /wimfile:${addFiles}\Sources\install.wim + DISM /Mount-Wim /WimFile:${addFiles}\Sources\install.wim /Index:1 /MountDir:${droot}\mount\install + DISM /Image:${droot}\mount\install /Add-Driver /Driver:${droot}\drivers\install /recurse /forceunsigned + DISM /Image:${droot}\mount\install /add-package /PackagePath:${droot}\addfiles\updates + Write-Host "Trenne install.wim..." + DISM /Unmount-Wim /MountDir:${droot}\mount\install /Commit +} +function CreateISO { + Write-Host "Erstelle neues Windows-Image ..." + + Write-Host " lösche Work-Verzeichnis ..." + Remove-Item -Path "${workPath}\*" -Force -Recurse + + Write-Host " kopiere originale ISO Dateien ..." + cp ${isoPath}\* ${workPath} -Recurse -Force + + Write-Host " kopiere zusäzliche Dateien ..." + cp ${addFiles}\* ${workPath} -Recurse -Force + + Write-Host "Erstelle ${isoOutfile} ..." + # $toolPath\oscdimg.exe -b"${toolPath}\efisys.bin" -udfver102 -u2 -h -m -o ${workPath} ${droot}\bootable.iso + Start-Process -Filepath "$toolPath\oscdimg.exe" -ArgumentList "-b`"${toolPath}\efisys.bin`" -udfver102 -u2 -h -m -o ${workPath} ${isoOutfile}" -Wait -WindowStyle Minimized +} +function CleanUp { + Write-Host "Räume auf..." + # HKLM\SOFTWARE\Microsoft\WIMMount\mounted images\ + DISM /Cleanup-Wim + DISM /Get-MountedImageInfo + DISM /Get-MountedWimInfo +} + +<# + +DiscardMounts +CreateDirs +CopyIso +ModifyBoot +ModifyInstall +CleanUp +CreateISO + +#>