50 lines
1.7 KiB
PowerShell
Executable File
50 lines
1.7 KiB
PowerShell
Executable File
# Parameter
|
|
$excelPath = "C:\Pfad\zu\hosts.xlsx"
|
|
$isoPath = "C:\Pfad\zu\original.iso"
|
|
$tempPath = "C:\Temp\IsoContents"
|
|
$newIsoPath = "C:\Pfad\zu\custom.iso"
|
|
|
|
# Import-Excel Modul laden
|
|
Import-Module ImportExcel
|
|
|
|
# Excel-Daten lesen
|
|
$hostsData = Import-Excel -Path $excelPath
|
|
|
|
# ISO mounten und Dateien kopieren
|
|
Mount-DiskImage -ImagePath $isoPath
|
|
$disk = Get-DiskImage -ImagePath $isoPath
|
|
$volume = Get-Volume -DiskImage $disk
|
|
Copy-Item -Path "$($volume.DriveLetter):\*" -Destination $tempPath -Recurse
|
|
Dismount-DiskImage -ImagePath $isoPath
|
|
|
|
# ks.cfg aktualisieren
|
|
$ksPath = "$tempPath\ks.cfg"
|
|
$configContent = Get-Content -Path $ksPath
|
|
|
|
foreach ($host in $hostsData) {
|
|
$hostname = $host.Hostname
|
|
$ip = $host.'IP-Adresse'
|
|
$netmask = $host.Netzmaske
|
|
$gateway = $host.Gateway
|
|
$dns = $host.'DNS-Server'
|
|
$username = $host.Benutzername
|
|
$password = $host.Passwort
|
|
$timezone = $host.Zeitzone
|
|
$partitioning = $host.Partitionierung
|
|
|
|
$configContent = $configContent -replace "<hostname_placeholder>", $hostname
|
|
$configContent = $configContent -replace "<ip_placeholder>", $ip
|
|
$configContent = $configContent -replace "<netmask_placeholder>", $netmask
|
|
$configContent = $configContent -replace "<gateway_placeholder>", $gateway
|
|
$configContent = $configContent -replace "<dns_placeholder>", $dns
|
|
$configContent = $configContent -replace "<password_placeholder>", $password
|
|
$configContent = $configContent -replace "<timezone_placeholder>", $timezone
|
|
$configContent = $configContent -replace "<partitioning_placeholder>", $partitioning
|
|
}
|
|
|
|
$configContent | Set-Content -Path $ksPath
|
|
|
|
# Neue ISO erstellen
|
|
& oscdimg -n -m -b"$tempPath\boot\etfsboot.com" $tempPath $newIsoPath
|
|
|
|
Write-Host "Neue ISO wurde erstellt: $newIsoPath" |