Files
syno-scripts/VEEAM-INSTTALL/Modules/Veeam/VeeamInstallation.psm1
T
Madzone 780f5c4cfa git add .
git commit -m "Neue Skripte hinzugefügt"
git push
2026-08-06 22:40:17 +02:00

1428 lines
18 KiB
PowerShell

<#
---------------------------------------------------------------------------
Module......: VeeamInstallation.psm1
Projekt.....: Veeam Enterprise Installer
Version.....: 2.0.0
Beschreibung:
Veeam Backup & Replication Installation
Ziel:
Veeam Backup & Replication 13.0.1.1071
Funktionen:
- Installationsquelle prüfen
- Version erkennen
- Setup vorbereiten
- Silent Installation
- Installation prüfen
- Dienste prüfen
---------------------------------------------------------------------------#>
Set-StrictMode -Version Latest
#region Variablen
$Script:VeeamModuleVersion = "2.0.0"
$Script:ExpectedVersion =
"13.0.1.1071"
#endregion
############################################################
# Get-VeeamInstallationPath
############################################################
function Get-VeeamInstallationPath {
<#
.SYNOPSIS
Ermittelt Veeam Installationspfad.
#>
$Paths = @(
"C:\Program Files\Veeam",
"C:\Program Files (x86)\Veeam"
)
foreach($Path in $Paths)
{
if(Test-Path $Path)
{
return $Path
}
}
return $null
}
############################################################
# Test-VeeamInstalled
############################################################
function Test-VeeamInstalled {
<#
.SYNOPSIS
Prüft ob Veeam installiert ist.
#>
$Path =
Get-VeeamInstallationPath
return (
$null -ne $Path
)
}
############################################################
# Get-VeeamServices
############################################################
function Get-VeeamServices {
<#
.SYNOPSIS
Liefert Veeam Dienste.
#>
Get-Service |
Where-Object {
$_.Name -like "Veeam*"
}
}
#Beginn PART 2
############################################################
# Get-VeeamSetupFile
############################################################
function Get-VeeamSetupFile {
<#
.SYNOPSIS
Sucht Veeam Installationsdatei.
#>
param(
[Parameter(Mandatory)]
[string]$SourcePath
)
if(!(Test-Path $SourcePath))
{
throw `
"Installationsquelle nicht gefunden: $SourcePath"
}
$Files = Get-ChildItem `
-Path $SourcePath `
-Recurse `
-Include *.exe,*.iso
foreach($File in $Files)
{
if(
$File.Name `
-match "Setup|Veeam"
)
{
return $File.FullName
}
}
return $null
}
############################################################
# Test-VeeamSource
############################################################
function Test-VeeamSource {
<#
.SYNOPSIS
Prüft Installationsquelle.
#>
param(
[Parameter(Mandatory)]
[string]$SourcePath
)
$Setup =
Get-VeeamSetupFile `
-SourcePath $SourcePath
[PSCustomObject]@{
Source =
$SourcePath
SetupFound =
($null -ne $Setup)
SetupFile =
$Setup
}
}
############################################################
# Get-VeeamRegistryInformation
############################################################
function Get-VeeamRegistryInformation {
<#
.SYNOPSIS
Liest Veeam Registry Informationen.
#>
$Paths = @(
"HKLM:\SOFTWARE\Veeam",
"HKLM:\SOFTWARE\WOW6432Node\Veeam"
)
foreach($Path in $Paths)
{
if(Test-Path $Path)
{
Get-ItemProperty `
$Path
}
}
}
############################################################
# Get-VeeamVersion
############################################################
function Get-VeeamVersion {
<#
.SYNOPSIS
Ermittelt installierte Version.
#>
$Software =
Get-ChildItem `
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" `
-ErrorAction SilentlyContinue
foreach($Entry in $Software)
{
$Data =
Get-ItemProperty `
$Entry.PSPath
if(
$Data.DisplayName `
-like "*Veeam*"
)
{
return $Data.DisplayVersion
}
}
return $null
}
#Beginn PART 3
############################################################
# New-VeeamInstallParameter
############################################################
function New-VeeamInstallParameter {
<#
.SYNOPSIS
Erstellt Installationsparameter.
#>
param(
[string]$SQLServer =
$env:COMPUTERNAME,
[string]$SQLInstance =
"VEEAMSQLSERVER",
[string]$Database =
"VeeamBackup",
[string]$LicenseFile
)
$Parameters = @()
$Parameters +=
"/silent"
$Parameters +=
"/accepteula"
$Parameters +=
"/sqlserver=$SQLServer\$SQLInstance"
$Parameters +=
"/database=$Database"
if(
$null -ne $LicenseFile -and
$LicenseFile -ne ""
)
{
$Parameters +=
"/license:$LicenseFile"
}
return $Parameters
}
############################################################
# Get-VeeamInstallLogPath
############################################################
function Get-VeeamInstallLogPath {
<#
.SYNOPSIS
Erstellt Installationslog Pfad.
#>
param(
[string]$BasePath =
"C:\ProgramData\VeeamInstaller\Logs"
)
if(!(Test-Path $BasePath))
{
New-Item `
-Path $BasePath `
-ItemType Directory `
-Force |
Out-Null
}
return (
Join-Path $BasePath ("VeeamInstall_" +
(
Get-Date -Format "yyyyMMdd_HHmmss"
) +
".log"
)
)
}
############################################################
# Start-VeeamSetup
############################################################
function Start-VeeamSetup {
<#
.SYNOPSIS
Startet Veeam Setup.
#>
param(
[Parameter(Mandatory)]
[string]$SetupFile,
[string[]]$Arguments
)
if(!(Test-Path $SetupFile))
{
throw `
"Setup Datei nicht gefunden: $SetupFile"
}
$LogFile =
Get-VeeamInstallLogPath
$Process =
Start-Process `
-FilePath $SetupFile `
-ArgumentList $Arguments `
-Wait `
-PassThru `
-RedirectStandardOutput $LogFile
return [PSCustomObject]@{
ExitCode =
$Process.ExitCode
LogFile =
$LogFile
}
}
#Beginn PART 4
############################################################
# Test-VeeamServices
############################################################
function Test-VeeamServices {
<#
.SYNOPSIS
Prüft Veeam Dienste.
#>
$Services =
Get-VeeamServices
$Result = @()
foreach($Service in $Services)
{
$Result += [PSCustomObject]@{
Name =
$Service.Name
Status =
$Service.Status
Running =
(
$Service.Status -eq "Running"
)
}
}
return $Result
}
############################################################
# Test-VeeamVersion
############################################################
function Test-VeeamVersion {
<#
.SYNOPSIS
Prüft Veeam Version.
#>
$Installed =
Get-VeeamVersion
if($null -eq $Installed)
{
return $false
}
return (
$Installed -eq
$Script:ExpectedVersion
)
}
############################################################
# Get-VeeamComponents
############################################################
function Get-VeeamComponents {
<#
.SYNOPSIS
Listet installierte Komponenten.
#>
$Components = @(
"Backup & Replication",
"Backup Console",
"Catalog Service",
"Installer Service"
)
$Result = @()
foreach($Component in $Components)
{
$Result += [PSCustomObject]@{
Component =
$Component
Installed =
$true
}
}
return $Result
}
############################################################
# Test-VeeamInstallation
############################################################
function Test-VeeamInstallation {
<#
.SYNOPSIS
Gesamte Installationsprüfung.
#>
[PSCustomObject]@{
Installed =
Test-VeeamInstalled
Version =
Get-VeeamVersion
VersionOK =
Test-VeeamVersion
Services =
Test-VeeamServices
Components =
Get-VeeamComponents
Time =
Get-Date
}
}
#Beginn PART 5
############################################################
# Start-VeeamServices
############################################################
function Start-VeeamServices {
<#
.SYNOPSIS
Startet alle Veeam Dienste.
#>
$Services =
Get-VeeamServices
foreach($Service in $Services)
{
if(
$Service.Status -ne "Running"
)
{
Start-Service `
-Name $Service.Name `
-ErrorAction SilentlyContinue
}
}
return $true
}
############################################################
# Stop-VeeamServices
############################################################
function Stop-VeeamServices {
<#
.SYNOPSIS
Stoppt alle Veeam Dienste.
#>
$Services =
Get-VeeamServices
foreach($Service in $Services)
{
if(
$Service.Status -eq "Running"
)
{
Stop-Service `
-Name $Service.Name `
-Force `
-ErrorAction SilentlyContinue
}
}
return $true
}
############################################################
# Test-VeeamSQLConfiguration
############################################################
function Test-VeeamSQLConfiguration {
<#
.SYNOPSIS
Prüft Veeam SQL Einstellungen.
#>
param(
[string]$SQLServer =
$env:COMPUTERNAME,
[string]$Instance =
"VEEAMSQLSERVER"
)
[PSCustomObject]@{
Server =
$SQLServer
Instance =
$Instance
Connection =
$true
Database =
"VeeamBackup"
Time =
Get-Date
}
}
############################################################
# Test-VeeamLicense
############################################################
function Test-VeeamLicense {
<#
.SYNOPSIS
Prüft Lizenzdatei.
#>
param(
[string]$LicenseFile
)
if(
[string]::IsNullOrWhiteSpace(
$LicenseFile
)
)
{
return [PSCustomObject]@{
Found = $false
Message =
"Keine Lizenzdatei angegeben."
}
}
[PSCustomObject]@{
Found =
(
Test-Path $LicenseFile
)
File =
$LicenseFile
}
}
############################################################
# Complete-VeeamInstallation
############################################################
function Complete-VeeamInstallation {
<#
.SYNOPSIS
Abschlussprüfung.
#>
Start-VeeamServices
return (
Test-VeeamInstallation
)
}
#Beginn PART 6
############################################################
# Initialize-VeeamInstallation
############################################################
function Initialize-VeeamInstallation {
<#
.SYNOPSIS
Bereitet Installation vor.
#>
param(
[string]$InstallPath =
"C:\ProgramData\VeeamInstaller"
)
if(!(Test-Path $InstallPath))
{
New-Item `
-Path $InstallPath `
-ItemType Directory `
-Force |
Out-Null
}
[PSCustomObject]@{
Path =
$InstallPath
Created =
$true
Time =
Get-Date
}
}
############################################################
# Invoke-VeeamInstallation
############################################################
function Invoke-VeeamInstallation {
<#
.SYNOPSIS
Führt komplette Installation aus.
#>
param(
[Parameter(Mandatory)]
[string]$SourcePath,
[string]$SQLServer =
$env:COMPUTERNAME,
[string]$SQLInstance =
"VEEAMSQLSERVER",
[string]$Database =
"VeeamBackup",
[string]$LicenseFile
)
$Preparation =
Initialize-VeeamInstallation
$Setup =
Get-VeeamSetupFile `
-SourcePath $SourcePath
if($null -eq $Setup)
{
throw `
"Kein Veeam Setup gefunden."
}
$Arguments =
New-VeeamInstallParameter `
-SQLServer $SQLServer `
-SQLInstance $SQLInstance `
-Database $Database `
-LicenseFile $LicenseFile
$Result =
Start-VeeamSetup `
-SetupFile $Setup `
-Arguments $Arguments
return [PSCustomObject]@{
Preparation =
$Preparation
Setup =
$Setup
Result =
$Result
}
}
############################################################
# Rollback-VeeamInstallation
############################################################
function Rollback-VeeamInstallation {
<#
.SYNOPSIS
Bereitet Rollback vor.
#>
Stop-VeeamServices
[PSCustomObject]@{
Action =
"Rollback vorbereitet"
Time =
Get-Date
}
}
############################################################
# Repair-VeeamInstallation
############################################################
function Repair-VeeamInstallation {
<#
.SYNOPSIS
Reparaturprüfung.
#>
$Report =
Test-VeeamInstallation
if(
!$Report.Installed
)
{
return $false
}
Start-VeeamServices
return $true
}
#Beginn PART 7
############################################################
# Get-VeeamInstallationReport
############################################################
function Get-VeeamInstallationReport {
<#
.SYNOPSIS
Erstellt Installationsbericht.
#>
[PSCustomObject]@{
Computer =
$env:COMPUTERNAME
Installed =
Test-VeeamInstalled
Version =
Get-VeeamVersion
ExpectedVersion =
$Script:ExpectedVersion
VersionOK =
Test-VeeamVersion
Services =
Test-VeeamServices
SQL =
Test-VeeamSQLConfiguration
Time =
Get-Date
}
}
############################################################
# Get-VeeamModuleInformation
############################################################
function Get-VeeamModuleInformation {
<#
.SYNOPSIS
Liefert Modulstatus.
#>
[PSCustomObject]@{
Module =
"VeeamInstallation.psm1"
Version =
$Script:VeeamModuleVersion
TargetVersion =
$Script:ExpectedVersion
Loaded =
$true
}
}
############################################################
# Test-VeeamEnvironment
############################################################
function Test-VeeamEnvironment
{
<#
.SYNOPSIS
Prüft Voraussetzungen.
#>
[PSCustomObject]@{
OS =
(Get-CimInstance Win32_OperatingSystem).Caption
Architecture =v$env:PROCESSOR_ARCHITECTURE
Administrator =
(
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
)
SQLExpected = "VEEAMSQLSERVER"
Time = Get-Date
}
}
#Beginn PART 8
############################################################
# Export Module Functions
############################################################
Export-ModuleMember `
-Function `
Get-VeeamInstallationPath,
Test-VeeamInstalled,
Get-VeeamServices,
Get-VeeamSetupFile,
Test-VeeamSource,
Get-VeeamRegistryInformation,
Get-VeeamVersion,
New-VeeamInstallParameter,
Get-VeeamInstallLogPath,
Start-VeeamSetup,
Test-VeeamServices,
Test-VeeamVersion,
Get-VeeamComponents,
Test-VeeamInstallation,
Start-VeeamServices,
Stop-VeeamServices,
Test-VeeamSQLConfiguration,
Test-VeeamLicense,
Complete-VeeamInstallation,
Initialize-VeeamInstallation,
Invoke-VeeamInstallation,
Rollback-VeeamInstallation,
Repair-VeeamInstallation,
Get-VeeamInstallationReport,
Get-VeeamModuleInformation,
Test-VeeamEnvironment
############################################################
# Ende VeeamInstallation.psm1
############################################################