Version 1.2

This commit is contained in:
Madzone
2026-08-11 09:52:19 +02:00
parent 284fe02796
commit 7f2eadf99f
7 changed files with 219 additions and 4 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
"Veeam": {
"Version": "13.0.1.1071",
"SourcePath": "D:\\Install\\Veeam13"
"SourcePath": "Auto"
},
"SQL": {
@@ -0,0 +1,53 @@
param(
[Parameter(Mandatory)]
[ValidateSet("VMware", "HyperV", "Proxmox")]
[string]$Platform,
[Parameter(Mandatory)]
[string]$Server,
[PSCredential]$Credential,
[switch]$DryRun
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
$RequiredModules = @(
"Modules\Veeam\BackupJobs.psm1",
"Modules\Platforms\$Platform.psm1"
)
foreach($Module in $RequiredModules) {
Import-Module (Join-Path $Root $Module) -Force -ErrorAction Stop
}
$Configuration = Get-Content (Join-Path $Root "Config\VeeamConfig.json") -Raw | ConvertFrom-Json
if($Platform -eq "Proxmox" -and $null -eq $Credential) {
$Credential = Get-Credential -Message "Proxmox API-Token-ID und Token-Secret eingeben"
}
switch($Platform) {
"VMware" { $VirtualMachines = @(Get-VMwareInventory -Server $Server) }
"HyperV" { $VirtualMachines = @(Get-HyperVInventory -Server $Server) }
"Proxmox" { $VirtualMachines = @(Get-ProxmoxInventory -Server $Server -ApiCredential $Credential) }
}
$Schedules = New-AlphabeticalBackupSchedules `
-JobName $Configuration.BackupJob.Name `
-VirtualMachines $VirtualMachines `
-ScheduleGroups @($Configuration.BackupJob.ScheduleGroups)
[PSCustomObject]@{
Platform = $Platform
Server = $Server
DryRun = $DryRun.IsPresent
VirtualMachineCount = $VirtualMachines.Count
VirtualMachines = $VirtualMachines
Schedules = $Schedules
JobsCreated = $false
Message = "Inventar gelesen und Zeitplanentwurf erstellt. Es wurden keine Veeam-Jobs angelegt."
}
+7 -3
View File
@@ -25,7 +25,8 @@ param(
[Parameter(Mandatory=$false)]
[string]$VeeamSourcePath = "D:\Install\Veeam13",
[AllowEmptyString()]
[string]$VeeamSourcePath,
[Parameter(Mandatory=$false)]
@@ -526,8 +527,7 @@ function Start-VeeamEnterpriseInstall {
param(
[Parameter(Mandatory)]
[AllowEmptyString()]
[string]$VeeamSourcePath,
@@ -545,6 +545,10 @@ function Start-VeeamEnterpriseInstall {
$Configuration = Get-InstallerConfiguration
$VeeamSourcePath = Resolve-VeeamSourcePath `
-SourcePath $VeeamSourcePath `
-ConfiguredPath ([string]$Configuration.Veeam.SourcePath)
$SystemCheck = Test-InstallerPrerequisites
if($Script:IsDryRun)
@@ -0,0 +1,20 @@
Set-StrictMode -Version Latest
function Get-HyperVInventory {
param([Parameter(Mandatory)][string]$Server)
foreach($Command in @("Get-VBRServer", "Find-VBRHvEntity")) {
if($null -eq (Get-Command $Command -ErrorAction SilentlyContinue)) {
throw "Veeam-Befehl nicht verfügbar: $Command"
}
}
$VBRServer = Get-VBRServer -Name $Server | Where-Object { $_.Type -in @("HvServer", "HvCluster", "Scvmm") } | Select-Object -First 1
if($null -eq $VBRServer) {
throw "Hyper-V-Server ist in Veeam nicht registriert: $Server"
}
@(Find-VBRHvEntity -Server $VBRServer -HostsAndVMs | Where-Object { $_.Type -match "Vm" } | Select-Object -ExpandProperty Name -Unique)
}
Export-ModuleMember -Function Get-HyperVInventory
@@ -0,0 +1,23 @@
Set-StrictMode -Version Latest
function Get-ProxmoxInventory {
param(
[Parameter(Mandatory)][string]$Server,
[Parameter(Mandatory)][PSCredential]$ApiCredential
)
$TokenSecret = $ApiCredential.GetNetworkCredential().Password
$Headers = @{ Authorization = "PVEAPIToken=$($ApiCredential.UserName)=$TokenSecret" }
$Uri = "https://$Server`:8006/api2/json/cluster/resources?type=vm"
try {
$Response = Invoke-RestMethod -Method Get -Uri $Uri -Headers $Headers -ErrorAction Stop
@($Response.data | Where-Object { $_.type -eq "qemu" } | Select-Object -ExpandProperty name -Unique)
}
finally {
$TokenSecret = $null
$Headers = $null
}
}
Export-ModuleMember -Function Get-ProxmoxInventory
@@ -0,0 +1,20 @@
Set-StrictMode -Version Latest
function Get-VMwareInventory {
param([Parameter(Mandatory)][string]$Server)
foreach($Command in @("Get-VBRServer", "Find-VBRViEntity")) {
if($null -eq (Get-Command $Command -ErrorAction SilentlyContinue)) {
throw "Veeam-Befehl nicht verfügbar: $Command"
}
}
$VBRServer = Get-VBRServer -Name $Server | Where-Object { $_.Type -in @("VC", "ESXi", "ESX") } | Select-Object -First 1
if($null -eq $VBRServer) {
throw "VMware-Server ist in Veeam nicht registriert: $Server"
}
@(Find-VBRViEntity -Server $VBRServer -VMsAndTemplates | Where-Object { $_.Type -match "Vm" } | Select-Object -ExpandProperty Name -Unique)
}
Export-ModuleMember -Function Get-VMwareInventory
@@ -199,6 +199,100 @@ function Get-VeeamSetupFile {
############################################################
# Resolve-VeeamSourcePath
############################################################
function Resolve-VeeamSourcePath {
<#
.SYNOPSIS
Ermittelt die Installationsquelle aus Parameter, Konfiguration
oder eingelegten DVD-/ISO-Laufwerken.
#>
param(
[AllowEmptyString()][string]$SourcePath,
[AllowEmptyString()][string]$ConfiguredPath
)
if(![string]::IsNullOrWhiteSpace($SourcePath)) {
$SetupFile = Get-VeeamSetupFile -SourcePath $SourcePath
if($null -eq $SetupFile) {
throw "Keine Veeam.Silent.Install.exe in der angegebenen Quelle gefunden: $SourcePath"
}
return (Resolve-Path -Path $SourcePath).Path
}
$Candidates = @()
if(
![string]::IsNullOrWhiteSpace($ConfiguredPath) -and
$ConfiguredPath -ne "Auto" -and
(Test-Path -Path $ConfiguredPath)
) {
$Candidates += $ConfiguredPath
}
if($env:OS -eq "Windows_NT") {
try {
$OpticalDrives = Get-CimInstance Win32_LogicalDisk -Filter "DriveType = 5" -ErrorAction Stop
foreach($Drive in $OpticalDrives) {
if(![string]::IsNullOrWhiteSpace([string]$Drive.DeviceID)) {
$Candidates += ("{0}\" -f $Drive.DeviceID)
}
}
}
catch {
Write-Verbose "DVD-/ISO-Laufwerke konnten nicht über CIM ermittelt werden: $($_.Exception.Message)"
}
}
$ValidSources = @()
foreach($Candidate in @($Candidates | Select-Object -Unique)) {
if(!(Test-Path -Path $Candidate)) { continue }
try {
$SetupFile = Get-VeeamSetupFile -SourcePath $Candidate
if($null -ne $SetupFile) {
$ValidSources += [PSCustomObject]@{
SourcePath = (Resolve-Path -Path $Candidate).Path
SetupFile = $SetupFile
}
}
}
catch {
Write-Verbose "Quelle wurde übersprungen: $Candidate"
}
}
if($ValidSources.Count -eq 0) {
throw "Keine Veeam-Installationsquelle gefunden. DVD/ISO einlegen oder -VeeamSourcePath angeben."
}
if($ValidSources.Count -eq 1) {
return $ValidSources[0].SourcePath
}
Write-Host ""
Write-Host "Mehrere Veeam-Installationsquellen gefunden:" -ForegroundColor Cyan
for($Index = 0; $Index -lt $ValidSources.Count; $Index++) {
Write-Host ("{0} - {1}" -f ($Index + 1), $ValidSources[$Index].SourcePath)
}
do {
$Selection = Read-Host "Installationsquelle auswählen (1-$($ValidSources.Count))"
$SelectedIndex = 0
$SelectionValid = [int]::TryParse($Selection, [ref]$SelectedIndex) -and
$SelectedIndex -ge 1 -and
$SelectedIndex -le $ValidSources.Count
} until($SelectionValid)
return $ValidSources[$SelectedIndex - 1].SourcePath
}
############################################################
# Test-VeeamSource
@@ -1370,6 +1464,7 @@ Export-ModuleMember `
Test-VeeamInstalled,
Get-VeeamServices,
Get-VeeamSetupFile,
Resolve-VeeamSourcePath,
Test-VeeamSource,
Get-VeeamRegistryInformation,
Get-VeeamVersion,