54 lines
1.8 KiB
PowerShell
Executable File
54 lines
1.8 KiB
PowerShell
Executable File
# PowerCLI-Modul laden
|
|
Import-Module VMware.PowerCLI
|
|
|
|
# Excel-Datei einlesen
|
|
$excelPath = "C:\Pfad\zu\esx_config.xlsx"
|
|
$hosts = Import-Excel -Path $excelPath -WorksheetName "Tabelle1"
|
|
|
|
# Login-Daten
|
|
$rootUser = "root"
|
|
|
|
# ESXi-Hosts konfigurieren
|
|
foreach ($host in $hosts) {
|
|
$hostname = $host.Hostname
|
|
$fqdn = $host.FQDN
|
|
$ip = $host."Mgmt Net IP"
|
|
$netmask = $host."Mgnt Netmask"
|
|
$gateway = $host."vSan GW"
|
|
$rootPassword = $host."root PW"
|
|
$vsanIp = $host."vSan IP"
|
|
$vsanNetmask = $host."vSAN Netmask"
|
|
$vsanGateway = $host."vSan GW"
|
|
$ssh = $host.SSH
|
|
$lockdown = $host."Lockdown Mode"
|
|
|
|
# Verbindung zum Host herstellen
|
|
Write-Host "Verbinde zu Host $hostname ($ip)..."
|
|
Connect-VIServer -Server $ip -User $rootUser -Password $rootPassword
|
|
|
|
# Hostname setzen
|
|
Write-Host "Setze Hostname auf $fqdn..."
|
|
Set-VMHost -VMHost $hostname -Name $fqdn
|
|
|
|
# Management-Netzwerk konfigurieren
|
|
Write-Host "Konfiguriere Management-Netzwerk..."
|
|
Get-VMHostNetworkAdapter -VMHost $hostname | Set-VMHostNetworkAdapter -IP $ip -SubnetMask $netmask -VMKernelGateway $gateway
|
|
|
|
# VSAN konfigurieren
|
|
Write-Host "Konfiguriere vSAN-Netzwerk..."
|
|
New-VMHostNetworkAdapter -VMHost $hostname -PortGroup vSAN -IP $vsanIp -SubnetMask $vsanNetmask -VMKernelGateway $vsanGateway -VMotionEnabled $true
|
|
|
|
# SSH und Lockdown Mode konfigurieren
|
|
Write-Host "Konfiguriere SSH und Lockdown Mode..."
|
|
if ($ssh -eq "enable") {
|
|
Get-VMHost | Get-VMHostService | Where-Object {$_.Key -eq "TSM-SSH"} | Start-VMHostService
|
|
}
|
|
if ($lockdown -eq "enable") {
|
|
Set-VMHost -VMHost $hostname -LockdownMode $true
|
|
}
|
|
|
|
# Verbindung trennen
|
|
Disconnect-VIServer -Confirm:$false
|
|
Write-Host "Host $hostname ($ip) konfiguriert!"
|
|
}
|