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
@@ -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,