Initialer Import der Synology Scripts

This commit is contained in:
root
2026-08-05 08:43:57 +02:00
commit 5e32a7c411
404 changed files with 79932 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
# Variablen
$TFTP_Root = "C:\PXE\TFTP"
$HTTP_Root = "C:\PXE\HTTP"
$KickstartFolder = "$HTTP_Root\kickstarts"
$ESXi_ISO = "C:\PXE\ISO\VMware-ESXi.iso"
$ExcelFile = "C:\PXE\Config.xlsx"
# Importiere das Modul "ImportExcel" (offline)
$ModulePath = "C:\PXE\Modules"
Write-Host "Importiere ImportExcel Modul..." -ForegroundColor Cyan
Import-Module "$ModulePath\ImportExcel" -Force
# Erstelle Verzeichnisstruktur
Write-Host "Erstelle Verzeichnisstruktur..." -ForegroundColor Cyan
New-Item -Path $TFTP_Root, $HTTP_Root, $KickstartFolder -ItemType Directory -Force
# Starte TFTP-Server (TFTPD64 offline)
Write-Host "Starte TFTP-Server..." -ForegroundColor Cyan
Start-Process -FilePath "C:\PXE\TFTPD\tftpd64.exe" -ArgumentList "-d $TFTP_Root" -PassThru
# HTTP-Server vorbereiten (IIS)
Write-Host "Konfiguriere HTTP-Server (IIS)..." -ForegroundColor Cyan
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
New-WebSite -Name "PXE-HTTP" -PhysicalPath $HTTP_Root -Port 80 -Force
# Extrahiere ESXi-Boot-Dateien
Write-Host "Extrahiere ESXi-Boot-Dateien..." -ForegroundColor Cyan
Mount-DiskImage -ImagePath $ESXi_ISO
$ISOMount = Get-Volume -FileSystemLabel "ESXI*" | Select-Object -ExpandProperty DriveLetter
Copy-Item -Path "$($ISOMount):\efi\*" -Destination $TFTP_Root -Recurse -Force
Dismount-DiskImage -ImagePath $ESXi_ISO
# Kickstart-Dateien erstellen
Write-Host "Erstelle Kickstart-Dateien..." -ForegroundColor Cyan
$Servers = Import-Excel -Path $ExcelFile
foreach ($Server in $Servers) {
$MAC = $Server.MAC
$IP = $Server.IP
$Hostname = $Server.Hostname
$Netmask = $Server.Netmask
$Gateway = $Server.Gateway
$DNS = $Server.DNS
$RootPass = $Server.RootPass
$KickstartFile = "$KickstartFolder\ks_$MAC.cfg"
$KickstartContent = @"
vmaccepteula
rootpw $RootPass
install --firstdisk --overwritevmfs
network --bootproto=static --ip=$IP --netmask=$Netmask --gateway=$Gateway --nameserver=$DNS --hostname=$Hostname
reboot
"@
Set-Content -Path $KickstartFile -Value $KickstartContent
Write-Host "Kickstart-Datei erstellt: ks_$MAC.cfg"
}
# PXE-Menü konfigurieren
Write-Host "Erstelle PXE-Boot-Menü..." -ForegroundColor Cyan
$PXEConfig = @"
DEFAULT menu.c32
PROMPT 0
TIMEOUT 300
MENU TITLE ESXi PXE Boot
"@
foreach ($Server in $Servers) {
$MAC = $Server.MAC
$PXEConfig += @"
LABEL Install_ESXi_$MAC
MENU LABEL Install ESXi - $MAC
KERNEL mboot.c32
APPEND -c boot.cfg ks=http://192.168.1.100/kickstarts/ks_$MAC.cfg
"@
}
$PXEFolder = "$TFTP_Root\pxelinux.cfg"
New-Item -Path $PXEFolder -ItemType Directory -Force
Set-Content -Path "$PXEFolder\default" -Value $PXEConfig
Write-Host "Offline PXE-Server erfolgreich vorbereitet!" -ForegroundColor Green