Version 1.2
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user