This commit is contained in:
Madzone
2026-08-10 22:10:17 +02:00
parent 9b22c39b5d
commit cf1b29452d
13 changed files with 14208 additions and 0 deletions
+583
View File
@@ -0,0 +1,583 @@
<#
---------------------------------------------------------------------------
Module......: Bootstrap.psm1
Projekt.....: Veeam Enterprise Installer
Version.....: 2.0.0
Autor.......: ChatGPT & Benutzer
PowerShell..: 5.1
---------------------------------------------------------------------------
Beschreibung
Initialisiert das komplette Installationsprojekt.
Dieses Modul
• bestimmt alle Projektpfade
• erstellt die Arbeitsverzeichnisse
• initialisiert globale Variablen
• legt Standardwerte fest
• erkennt das Betriebssystem
• stellt Informationen allen Modulen bereit
Dieses Modul MUSS zuerst geladen werden.
#>
Set-StrictMode -Version Latest
#region Script Variablen
$Script:ProjectName = "Veeam Enterprise Installer"
$Script:ProjectVersion = "2.0.0"
$Script:RootPath = $null
$Script:ModulePath = $null
$Script:ConfigPath = $null
$Script:ResourcePath = $null
$Script:ReportPath = $null
$Script:LogPath = $null
$Script:TempPath = $null
$Script:LogFile = $null
$Script:TranscriptFile = $null
$Script:Configuration = $null
#endregion
############################################################
# Get-ProjectRoot
############################################################
function Get-ProjectRoot {
<#
.SYNOPSIS
Ermittelt den Projektordner.
#>
$ModulesPath = Split-Path -Path $PSScriptRoot -Parent
Split-Path -Path $ModulesPath -Parent
}
############################################################
# Initialize-Paths
############################################################
function Initialize-Paths {
<#
.SYNOPSIS
Initialisiert sämtliche Projektpfade.
#>
$Script:RootPath =
Get-ProjectRoot
$Script:ModulePath = Join-Path `
-Path $Script:RootPath `
-ChildPath "Modules"
$Script:ConfigPath = Join-Path `
-Path $Script:RootPath `
-ChildPath "Config"
$Script:ResourcePath = Join-Path `
-Path $Script:RootPath `
-ChildPath "Resources"
$Script:ReportPath = Join-Path `
-Path $Script:RootPath `
-ChildPath "Reports"
$Script:LogPath = Join-Path `
-Path $Script:RootPath `
-ChildPath "Logs"
$Script:TempPath = Join-Path `
-Path $Script:RootPath `
-ChildPath "Temp"
$Script:LogFile = Join-Path `
-Path $Script:LogPath `
-ChildPath "Install.log"
$Script:TranscriptFile = Join-Path `
-Path $Script:LogPath `
-ChildPath "Transcript.log"
}
############################################################
# New-ProjectDirectory
############################################################
function New-ProjectDirectory {
param(
[Parameter(Mandatory)]
[string]$Path
)
if(Test-Path $Path)
{
return
}
New-Item `
-Path $Path `
-ItemType Directory `
-Force | Out-Null
}
############################################################
# Initialize-Directories
############################################################
function Initialize-Directories {
<#
.SYNOPSIS
Erstellt alle Projektverzeichnisse.
#>
$Folders = @(
$Script:ModulePath
$Script:ConfigPath
$Script:ResourcePath
$Script:ReportPath
$Script:LogPath
$Script:TempPath
)
foreach($Folder in $Folders)
{
New-ProjectDirectory `
-Path $Folder
}
}
#Beginn PART 2
############################################################
# Get-OperatingSystem
############################################################
function Get-OperatingSystem {
<#
.SYNOPSIS
Liefert Informationen zum Betriebssystem.
#>
try {
Get-CimInstance `
Win32_OperatingSystem
}
catch {
throw "Betriebssystem konnte nicht ermittelt werden."
}
}
############################################################
# Get-BuildNumber
############################################################
function Get-BuildNumber {
<#
.SYNOPSIS
Liefert die Windows Buildnummer.
#>
(Get-OperatingSystem).BuildNumber
}
############################################################
# Get-PowerShellVersion
############################################################
function Get-PowerShellVersion {
<#
.SYNOPSIS
Liefert die installierte PowerShell Version.
#>
$PSVersionTable.PSVersion
}
############################################################
# Test-Administrator
############################################################
function Test-Administrator {
<#
.SYNOPSIS
Prüft Administratorrechte.
#>
$Identity =
[Security.Principal.WindowsIdentity]::GetCurrent()
$Principal =
New-Object Security.Principal.WindowsPrincipal($Identity)
return $Principal.IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
}
############################################################
# Test-SupportedOperatingSystem
############################################################
function Test-SupportedOperatingSystem {
<#
.SYNOPSIS
Unterstützt Windows Server 2022 und 2025.
#>
$OS = Get-OperatingSystem
$Caption = $OS.Caption
if(
$Caption -match "Windows Server 2022" -or
$Caption -match "Windows Server 2025"
)
{
return $true
}
return $false
}
############################################################
# Get-ComputerInformation
############################################################
function Get-ComputerInformation {
<#
.SYNOPSIS
Erstellt ein Objekt mit Basisinformationen.
#>
$OS = Get-OperatingSystem
[PSCustomObject]@{
ComputerName = $env:COMPUTERNAME
Domain = $env:USERDOMAIN
User = $env:USERNAME
OperatingSystem = $OS.Caption
Version = $OS.Version
Build = $OS.BuildNumber
Architecture = $OS.OSArchitecture
PowerShellVersion = Get-PowerShellVersion
InstallDate = $OS.InstallDate
LastBoot = $OS.LastBootUpTime
}
}
############################################################
# Test-Bootstrap
############################################################
function Test-Bootstrap {
<#
.SYNOPSIS
Führt Grundprüfungen aus.
#>
if(!(Test-Administrator))
{
throw "Das Skript muss als Administrator ausgeführt werden."
}
if(!(Test-SupportedOperatingSystem))
{
throw "Nur Windows Server 2022 und 2025 werden unterstützt."
}
$MinimumPowerShellVersion = [version]"5.1"
if((Get-PowerShellVersion) -lt $MinimumPowerShellVersion)
{
throw "PowerShell 5.1 oder neuer wird benötigt."
}
}
#Beginn PART 3
############################################################
# Get-ProjectInformation
############################################################
function Get-ProjectInformation {
<#
.SYNOPSIS
Liefert Projektinformationen.
#>
[PSCustomObject]@{
ProjectName = $Script:ProjectName
Version = $Script:ProjectVersion
RootPath = $Script:RootPath
ModulePath = $Script:ModulePath
ConfigPath = $Script:ConfigPath
ResourcePath = $Script:ResourcePath
ReportPath = $Script:ReportPath
LogPath = $Script:LogPath
TempPath = $Script:TempPath
LogFile = $Script:LogFile
TranscriptFile = $Script:TranscriptFile
}
}
############################################################
# Show-BootstrapBanner
############################################################
function Show-BootstrapBanner {
Write-Host ""
Write-Host "========================================================="
Write-Host " Veeam Enterprise Installer"
Write-Host "========================================================="
Write-Host "Version : $Script:ProjectVersion"
Write-Host "Computer : $env:COMPUTERNAME"
Write-Host "Benutzer : $env:USERNAME"
Write-Host "Projektpfad : $Script:RootPath"
Write-Host "========================================================="
Write-Host ""
}
############################################################
# Initialize-Bootstrap
############################################################
function Initialize-Bootstrap {
<#
.SYNOPSIS
Initialisiert das komplette Framework.
#>
Test-Bootstrap
Initialize-Paths
Initialize-Directories
$Info = Get-ProjectInformation
Write-Host ""
Write-Host "Projekt initialisiert"
Write-Host "Root : $($Info.RootPath)"
Write-Host "Config : $($Info.ConfigPath)"
Write-Host "Logs : $($Info.LogPath)"
Write-Host "Reports : $($Info.ReportPath)"
Write-Host "Temp : $($Info.TempPath)"
Show-BootstrapBanner
}
############################################################
# Get-EnvironmentSummary
############################################################
function Get-EnvironmentSummary {
$Computer = Get-ComputerInformation
[PSCustomObject]@{
ProjectVersion = $Script:ProjectVersion
ComputerName = $Computer.ComputerName
Domain = $Computer.Domain
User = $Computer.User
OperatingSystem = $Computer.OperatingSystem
Build = $Computer.Build
Architecture = $Computer.Architecture
PowerShell = $Computer.PowerShellVersion
RootPath = $Script:RootPath
LogPath = $Script:LogPath
ReportPath = $Script:ReportPath
TempPath = $Script:TempPath
}
}
############################################################
# Reset-Bootstrap
############################################################
function Reset-Bootstrap {
$Script:Configuration = $null
}
#Beginn PART 4
############################################################
# Get-ProjectPaths
############################################################
function Get-ProjectPaths {
<#
.SYNOPSIS
Gibt alle Projektpfade zurück.
#>
return [PSCustomObject]@{
Root = $Script:RootPath
Modules = $Script:ModulePath
Config = $Script:ConfigPath
Resources = $Script:ResourcePath
Reports = $Script:ReportPath
Logs = $Script:LogPath
Temp = $Script:TempPath
LogFile = $Script:LogFile
Transcript = $Script:TranscriptFile
}
}
############################################################
# Set-ProjectConfiguration
############################################################
function Set-ProjectConfiguration {
param(
[Parameter(Mandatory)]
[psobject]$Configuration
)
$Script:Configuration = $Configuration
}
############################################################
# Get-ProjectConfiguration
############################################################
function Get-ProjectConfiguration {
return $Script:Configuration
}
############################################################
# Test-ProjectInitialized
############################################################
function Test-ProjectInitialized {
if([string]::IsNullOrWhiteSpace($Script:RootPath))
{
return $false
}
if(!(Test-Path $Script:RootPath))
{
return $false
}
return $true
}
############################################################
# Initialize beim Import NICHT automatisch ausführen
############################################################
# Die Initialisierung erfolgt ausschließlich
# über Initialize-Bootstrap() im Hauptskript.
############################################################
# Exportierte Funktionen
############################################################
Export-ModuleMember `
-Function `
Initialize-Bootstrap,
Test-Bootstrap,
Test-Administrator,
Test-SupportedOperatingSystem,
Get-OperatingSystem,
Get-BuildNumber,
Get-PowerShellVersion,
Get-ComputerInformation,
Get-ProjectInformation,
Get-ProjectPaths,
Get-EnvironmentSummary,
Set-ProjectConfiguration,
Get-ProjectConfiguration,
Test-ProjectInitialized,
Reset-Bootstrap
############################################################
# Ende Bootstrap.psm1
############################################################
File diff suppressed because it is too large Load Diff
+688
View File
@@ -0,0 +1,688 @@
<#
.SYNOPSIS
Dry-Run Funktionen für Veeam Enterprise Installer.
.DESCRIPTION
Simuliert Installationsschritte ohne Änderungen.
.VERSION
1.0.0
#>
Set-StrictMode -Version Latest
############################################################
# Variablen
############################################################
$Script:DryRunVersion =
"2.0.0"
$Script:DryRunEnabled =
$false
############################################################
# Get-DryRunStatus
############################################################
function Get-DryRunStatus {
<#
.SYNOPSIS
Liefert Dry-Run Status.
#>
[PSCustomObject]@{
Enabled =
$Script:DryRunEnabled
Mode =
if($Script:DryRunEnabled)
{
"Simulation"
}
else
{
"Disabled"
}
Version =
$Script:DryRunVersion
Time =
Get-Date
}
}
############################################################
# Enable-DryRunMode
############################################################
function Enable-DryRunMode {
<#
.SYNOPSIS
Aktiviert Dry-Run.
#>
$Script:DryRunEnabled =
$true
return $true
}
############################################################
# Disable-DryRunMode
############################################################
function Disable-DryRunMode {
<#
.SYNOPSIS
Deaktiviert Dry-Run.
#>
$Script:DryRunEnabled =
$false
return $true
}
#Beginn PART 2
############################################################
# Invoke-DryRunAction
############################################################
function Invoke-DryRunAction {
<#
.SYNOPSIS
Simuliert eine Aktion.
#>
param(
[Parameter(Mandatory)]
[string]$Action,
[hashtable]$Parameters
)
if(!$Script:DryRunEnabled)
{
throw "Dry-Run-Modus ist nicht aktiviert."
}
[PSCustomObject]@{
Action =
$Action
Parameters =
$Parameters
Executed =
$false
Mode =
"DryRun"
Message =
"Aktion wurde nur simuliert."
Time =
Get-Date
}
}
############################################################
# Test-DryRunInstallation
############################################################
function Test-DryRunInstallation {
<#
.SYNOPSIS
Simuliert Veeam Installation.
#>
param(
[Parameter(Mandatory)]
[string]$SourcePath,
[Parameter(Mandatory)]
[string]$SQLServer,
[Parameter(Mandatory)]
[string]$Database
)
Invoke-DryRunAction `
-Action "Install Veeam Backup & Replication" `
-Parameters @{
Source =
$SourcePath
SQLServer =
$SQLServer
Database =
$Database
}
}
############################################################
# Test-DryRunRepository
############################################################
function Test-DryRunRepository {
<#
.SYNOPSIS
Simuliert Repository Erstellung.
#>
param(
[Parameter(Mandatory)]
[string]$Name,
[Parameter(Mandatory)]
[string]$Path
)
Invoke-DryRunAction `
-Action "Create Backup Repository" `
-Parameters @{
Name =
$Name
Path =
$Path
}
}
#Beginn PART 3
############################################################
# Test-DryRunBackupJob
############################################################
function Test-DryRunBackupJob {
<#
.SYNOPSIS
Simuliert Backup Job Erstellung.
#>
param(
[Parameter(Mandatory)]
[string]$Name,
[Parameter(Mandatory)]
[string]$Repository,
[ValidateRange(1, 9999)]
[int]$RetentionDays = 14
)
Invoke-DryRunAction `
-Action "Create Backup Job" `
-Parameters @{
JobName =
$Name
Repository =
$Repository
RetentionDays =
$RetentionDays
}
}
############################################################
# Invoke-DryRunPipeline
############################################################
function Invoke-DryRunPipeline {
<#
.SYNOPSIS
Simuliert komplette Installation.
#>
param(
[Parameter(Mandatory)]
[PSCustomObject]$Configuration
)
if(!$Script:DryRunEnabled)
{
throw "Dry-Run-Modus ist nicht aktiviert."
}
$Results = @()
$Results +=
Test-DryRunInstallation `
-SourcePath $Configuration.Veeam.SourcePath `
-SQLServer $Configuration.SQL.Server `
-Database $Configuration.SQL.Database
$Results +=
Test-DryRunRepository `
-Name $Configuration.Repository.Name `
-Path $Configuration.Repository.Path
$Results +=
Test-DryRunBackupJob `
-Name $Configuration.BackupJob.Name `
-Repository $Configuration.Repository.Name `
-RetentionDays $Configuration.Repository.RetentionDays
return $Results
}
############################################################
# Get-DryRunReport
############################################################
function Get-DryRunReport {
<#
.SYNOPSIS
Erstellt Dry-Run Bericht.
#>
param(
[Parameter(Mandatory)]
[array]$Results
)
[PSCustomObject]@{
Mode =
"DryRun"
Actions =
$Results.Count
Details =
$Results
Created =
Get-Date
}
}
#Beginn PART 4
############################################################
# Save-DryRunReport
############################################################
function Save-DryRunReport {
<#
.SYNOPSIS
Speichert Dry-Run Bericht.
#>
param(
[Parameter(Mandatory)]
[PSCustomObject]$Report,
[string]$Path
)
if([string]::IsNullOrWhiteSpace($Path))
{
$Path = (Get-ProjectPaths).Reports
}
if([string]::IsNullOrWhiteSpace($Path))
{
throw "Bootstrap wurde noch nicht initialisiert."
}
if(!(Test-Path $Path))
{
New-Item `
-Path $Path `
-ItemType Directory `
-Force |
Out-Null
}
$File =
Join-Path `
$Path `
(
"DryRun_" +
(
Get-Date `
-Format "yyyyMMdd_HHmmss"
) +
".json"
)
$Report |
ConvertTo-Json `
-Depth 10 |
Out-File `
-FilePath $File `
-Encoding UTF8
return $File
}
############################################################
# Test-DryRunConfiguration
############################################################
function Test-DryRunConfiguration {
<#
.SYNOPSIS
Prüft Dry-Run Konfiguration.
#>
param(
[Parameter(Mandatory)]
[PSCustomObject]$Configuration
)
$RepositoryProperty = $Configuration.PSObject.Properties["Repository"]
$SQLProperty = $Configuration.PSObject.Properties["SQL"]
$BackupJobProperty = $Configuration.PSObject.Properties["BackupJob"]
$RepositoryDefined =
$null -ne $RepositoryProperty -and
$null -ne $RepositoryProperty.Value -and
$null -ne $RepositoryProperty.Value.PSObject.Properties["Path"] -and
![string]::IsNullOrWhiteSpace(
[string]$RepositoryProperty.Value.PSObject.Properties["Path"].Value
)
$DatabaseDefined =
$null -ne $SQLProperty -and
$null -ne $SQLProperty.Value -and
$null -ne $SQLProperty.Value.PSObject.Properties["Database"] -and
![string]::IsNullOrWhiteSpace(
[string]$SQLProperty.Value.PSObject.Properties["Database"].Value
)
$JobDefined =
$null -ne $BackupJobProperty -and
$null -ne $BackupJobProperty.Value -and
$null -ne $BackupJobProperty.Value.PSObject.Properties["Name"] -and
![string]::IsNullOrWhiteSpace(
[string]$BackupJobProperty.Value.PSObject.Properties["Name"].Value
)
[PSCustomObject]@{
RepositoryDefined =
$RepositoryDefined
DatabaseDefined =
$DatabaseDefined
JobDefined =
$JobDefined
Valid =
(
$RepositoryDefined -and
$DatabaseDefined -and
$JobDefined
)
Checked =
Get-Date
}
}
#Beginn PART 5
############################################################
# Export Module Functions
############################################################
Export-ModuleMember `
-Function `
Get-DryRunStatus,
Enable-DryRunMode,
Disable-DryRunMode,
Invoke-DryRunAction,
Test-DryRunInstallation,
Test-DryRunRepository,
Test-DryRunBackupJob,
Invoke-DryRunPipeline,
Get-DryRunReport,
Save-DryRunReport,
Test-DryRunConfiguration
############################################################
# Ende DryRun.psm1
############################################################
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff