git add .
git commit -m "Neue Skripte hinzugefügt" git push
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"Environment": {
|
||||||
|
"Name": "Production",
|
||||||
|
"Owner": "IT"
|
||||||
|
},
|
||||||
|
|
||||||
|
"Veeam": {
|
||||||
|
"Version": "13.0.1.1071",
|
||||||
|
"SourcePath": "D:\\Install\\Veeam13"
|
||||||
|
},
|
||||||
|
|
||||||
|
"SQL": {
|
||||||
|
"Server": "SERVER01",
|
||||||
|
"Instance": "VEEAMSQLSERVER",
|
||||||
|
"Database": "VeeamBackup"
|
||||||
|
},
|
||||||
|
|
||||||
|
"Repository": {
|
||||||
|
"Name": "PrimaryRepository",
|
||||||
|
"Path": "D:\\VeeamRepository",
|
||||||
|
"RetentionDays": 30
|
||||||
|
},
|
||||||
|
|
||||||
|
"BackupJob": {
|
||||||
|
"Name": "ServerBackup",
|
||||||
|
"Schedule": "22:00",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"Options": {
|
||||||
|
"ApplicationAware": true,
|
||||||
|
"Encryption": true,
|
||||||
|
"Compression": "Optimal"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,909 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Veeam Enterprise Installer
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Automatisierte Installation und Konfiguration von:
|
||||||
|
- Veeam Backup & Replication
|
||||||
|
- SQL Konfiguration
|
||||||
|
- Repository
|
||||||
|
- Backup Jobs
|
||||||
|
- Reporting
|
||||||
|
- Logging
|
||||||
|
- Dry-Run Unterstützung
|
||||||
|
|
||||||
|
.VERSION
|
||||||
|
1.0.0
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
Set-StrictMode -Version Latest
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Script Parameter
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
|
||||||
|
[string]$VeeamSourcePath =
|
||||||
|
|
||||||
|
"D:\Install\Veeam13",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
|
||||||
|
[switch]$DryRun
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Globale Variablen
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
$Script:InstallerRoot =
|
||||||
|
|
||||||
|
Split-Path `
|
||||||
|
$PSScriptRoot `
|
||||||
|
-Parent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Script:ModulePath =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
$Script:InstallerRoot `
|
||||||
|
"Modules"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Script:ConfigPath =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
$Script:InstallerRoot `
|
||||||
|
"Config\VeeamConfig.json"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Import Installer Module
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Import-InstallerModules {
|
||||||
|
|
||||||
|
|
||||||
|
$Modules = @(
|
||||||
|
|
||||||
|
"Core\Logging.psm1",
|
||||||
|
|
||||||
|
"Core\Configuration.psm1",
|
||||||
|
|
||||||
|
"Core\Utilities.psm1",
|
||||||
|
|
||||||
|
"Core\Security.psm1",
|
||||||
|
|
||||||
|
"Core\SQL.psm1",
|
||||||
|
|
||||||
|
"Core\DryRun.psm1",
|
||||||
|
|
||||||
|
"Veeam\VeeamInstallation.psm1",
|
||||||
|
|
||||||
|
"Veeam\Repository.psm1",
|
||||||
|
|
||||||
|
"Veeam\BackupJobs.psm1"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach($Module in $Modules)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$Path =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
|
||||||
|
$Script:ModulePath `
|
||||||
|
|
||||||
|
$Module
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(Test-Path $Path)
|
||||||
|
{
|
||||||
|
|
||||||
|
Import-Module `
|
||||||
|
|
||||||
|
$Path `
|
||||||
|
|
||||||
|
-Force
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
throw `
|
||||||
|
|
||||||
|
"Modul nicht gefunden: $Path"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#Begin PART 2
|
||||||
|
############################################################
|
||||||
|
# Installer Initialisierung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Initialize-Installer {
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Initialisiere Veeam Enterprise Installer..." `
|
||||||
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Test-AdministratorRights
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Import-InstallerModules
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Module erfolgreich geladen." `
|
||||||
|
-ForegroundColor Green
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Administrator Prüfung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Test-AdministratorRights {
|
||||||
|
|
||||||
|
|
||||||
|
$CurrentUser =
|
||||||
|
|
||||||
|
[Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Principal =
|
||||||
|
|
||||||
|
New-Object `
|
||||||
|
Security.Principal.WindowsPrincipal(
|
||||||
|
$CurrentUser
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(
|
||||||
|
!$Principal.IsInRole(
|
||||||
|
[Security.Principal.WindowsBuiltInRole]::Administrator
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw `
|
||||||
|
"Script muss als Administrator ausgeführt werden."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Konfiguration laden
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Get-InstallerConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
$Config =
|
||||||
|
|
||||||
|
Get-VeeamConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Validation =
|
||||||
|
|
||||||
|
Test-VeeamConfig `
|
||||||
|
|
||||||
|
-Configuration $Config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!$Validation.Valid)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw `
|
||||||
|
"Konfigurationsprüfung fehlgeschlagen."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $Config
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Voraussetzungen prüfen
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Test-InstallerPrerequisites {
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Prüfe Systemvoraussetzungen..." `
|
||||||
|
-ForegroundColor Yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Checks = @()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Checks +=
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
Name =
|
||||||
|
|
||||||
|
"Administrator"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Result =
|
||||||
|
|
||||||
|
$true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Checks +=
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
Name =
|
||||||
|
|
||||||
|
"PowerShell"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Result =
|
||||||
|
|
||||||
|
(
|
||||||
|
$PSVersionTable.PSVersion.Major -ge 5
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $Checks
|
||||||
|
|
||||||
|
}
|
||||||
|
#Begin PART 3
|
||||||
|
############################################################
|
||||||
|
# SQL Prüfung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Test-InstallerSQL {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[PSCustomObject]$Configuration
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Prüfe SQL Konfiguration..." `
|
||||||
|
-ForegroundColor Yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Result =
|
||||||
|
|
||||||
|
Test-SQLConfiguration `
|
||||||
|
|
||||||
|
-Server $Configuration.SQL.Server `
|
||||||
|
|
||||||
|
-Instance $Configuration.SQL.Instance `
|
||||||
|
|
||||||
|
-Database $Configuration.SQL.Database
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $Result
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Veeam Installation
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Install-VeeamProduct {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[PSCustomObject]$Configuration,
|
||||||
|
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[string]$SourcePath
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Installiere Veeam..." `
|
||||||
|
-ForegroundColor Yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($DryRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
Test-DryRunInstallation -SourcePath $SourcePath -SQLServer $Configuration.SQL.Server -Database $Configuration.SQL.Database
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
Invoke-VeeamInstallation -SourcePath $SourcePath -SQLServer $Configuration.SQL.Server -SQLInstance $Configuration.SQL.Instance -Database $Configuration.SQL.Database
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Repository Initialisierung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Initialize-BackupRepository {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[PSCustomObject]$Configuration
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Erstelle Repository..." `
|
||||||
|
-ForegroundColor Yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($DryRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
Test-DryRunRepository -Name $Configuration.Repository.Name -Path $Configuration.Repository.Path
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
Deploy-RepositoryConfiguration -Name $Configuration.Repository.Name -Path $Configuration.Repository.Path -RetentionDays $Configuration.Repository.RetentionDays
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
#Begin PART 4
|
||||||
|
############################################################
|
||||||
|
# Backup Job Initialisierung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Initialize-BackupJobs
|
||||||
|
{
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[PSCustomObject]$Configuration
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Erstelle Backup Jobs..." `
|
||||||
|
-ForegroundColor Yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($DryRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
Test-DryRunBackupJob -Name $Configuration.BackupJob.Name -Repository $Configuration.Repository.Name -RetentionDays $Configuration.Repository.RetentionDays
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Job =
|
||||||
|
|
||||||
|
New-BackupJobDefinition `
|
||||||
|
|
||||||
|
-Name $Configuration.BackupJob.Name `
|
||||||
|
|
||||||
|
-Repository $Configuration.Repository.Name `
|
||||||
|
|
||||||
|
-RetentionDays $Configuration.Repository.RetentionDays
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Schedule = New-BackupSchedule -Time $Configuration.BackupJob.Schedule
|
||||||
|
|
||||||
|
$ApplicationAware = New-ApplicationAwareConfiguration -Enabled $Configuration.Options.ApplicationAware
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
Job = $Job
|
||||||
|
|
||||||
|
Schedule = $Schedule
|
||||||
|
|
||||||
|
ApplicationAware = $ApplicationAware
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Haupt Installationsablauf
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Start-VeeamEnterpriseInstall {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[string]$VeeamSourcePath
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$Configuration = Get-InstallerConfiguration
|
||||||
|
|
||||||
|
if($DryRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host "DRY-RUN aktiviert" -ForegroundColor Yellow
|
||||||
|
|
||||||
|
$Simulation = Invoke-DryRunPipeline -Configuration $Configuration
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
Get-DryRunReport -Results $Simulation
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$SystemCheck = Test-InstallerPrerequisites
|
||||||
|
|
||||||
|
$SQLCheck = Test-InstallerSQL -Configuration $Configuration
|
||||||
|
|
||||||
|
$Installation = Install-VeeamProduct -Configuration $Configuration -SourcePath $VeeamSourcePath
|
||||||
|
|
||||||
|
$Repository = Initialize-BackupRepository -Configuration $Configuration
|
||||||
|
|
||||||
|
$Jobs = Initialize-BackupJobs -Configuration $Configuration
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
|
||||||
|
Configuration = $Configuration
|
||||||
|
|
||||||
|
System = $SystemCheck
|
||||||
|
|
||||||
|
SQL = $SQLCheck
|
||||||
|
|
||||||
|
Installation = $Installation
|
||||||
|
|
||||||
|
Repository = $Repository
|
||||||
|
|
||||||
|
Jobs =$Jobs
|
||||||
|
|
||||||
|
Completed = Get-Date
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Write-ExceptionLog -Exception $_.Exception -Context "Installation"
|
||||||
|
throw
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#Begin PART 5
|
||||||
|
############################################################
|
||||||
|
# Enterprise Report
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Get-EnterpriseInstallationReport {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[PSCustomObject]$Result
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
Computer =
|
||||||
|
|
||||||
|
$env:COMPUTERNAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Mode =
|
||||||
|
|
||||||
|
if($DryRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
"DryRun"
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
"Production"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VeeamVersion =
|
||||||
|
|
||||||
|
$Result.Configuration.Veeam.Version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SQLServer =
|
||||||
|
|
||||||
|
$Result.Configuration.SQL.Server
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SQLInstance =
|
||||||
|
|
||||||
|
$Result.Configuration.SQL.Instance
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Database =
|
||||||
|
|
||||||
|
$Result.Configuration.SQL.Database
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Repository =
|
||||||
|
|
||||||
|
$Result.Configuration.Repository.Path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BackupJob =
|
||||||
|
|
||||||
|
$Result.Configuration.BackupJob.Name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Completed =
|
||||||
|
|
||||||
|
Get-Date
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Report speichern
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Save-EnterpriseReport {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[PSCustomObject]$Report
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Path =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
|
||||||
|
$Script:InstallerRoot `
|
||||||
|
|
||||||
|
"Reports"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!(Test-Path $Path))
|
||||||
|
{
|
||||||
|
|
||||||
|
New-Item `
|
||||||
|
|
||||||
|
-Path $Path `
|
||||||
|
|
||||||
|
-ItemType Directory `
|
||||||
|
|
||||||
|
-Force |
|
||||||
|
|
||||||
|
Out-Null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$File =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
|
||||||
|
$Path `
|
||||||
|
|
||||||
|
(
|
||||||
|
"EnterpriseReport_" +
|
||||||
|
|
||||||
|
(
|
||||||
|
Get-Date `
|
||||||
|
-Format "yyyyMMdd_HHmmss"
|
||||||
|
) +
|
||||||
|
|
||||||
|
".json"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Report |
|
||||||
|
|
||||||
|
ConvertTo-Json `
|
||||||
|
|
||||||
|
-Depth 10 |
|
||||||
|
|
||||||
|
Out-File `
|
||||||
|
|
||||||
|
-FilePath $File `
|
||||||
|
|
||||||
|
-Encoding UTF8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $File
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Hauptausführung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
Initialize-Installer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Initialize-EnterpriseLog `
|
||||||
|
|
||||||
|
-Name "VeeamEnterprise"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-EnterpriseLog `
|
||||||
|
|
||||||
|
-Level INFO `
|
||||||
|
|
||||||
|
-Message "Installer gestartet"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($DryRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
Enable-DryRunMode
|
||||||
|
|
||||||
|
Write-EnterpriseLog `
|
||||||
|
|
||||||
|
-Level INFO `
|
||||||
|
|
||||||
|
-Message "DryRun aktiviert"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Result =
|
||||||
|
|
||||||
|
Start-VeeamEnterpriseInstall `
|
||||||
|
|
||||||
|
-VeeamSourcePath $VeeamSourcePath
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Report =
|
||||||
|
|
||||||
|
Get-EnterpriseInstallationReport `
|
||||||
|
|
||||||
|
-Result $Result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ReportFile =
|
||||||
|
|
||||||
|
Save-EnterpriseReport `
|
||||||
|
|
||||||
|
-Report $Report
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-EnterpriseLog `
|
||||||
|
|
||||||
|
-Level INFO `
|
||||||
|
|
||||||
|
-Message (
|
||||||
|
|
||||||
|
"Installation abgeschlossen: " +
|
||||||
|
$ReportFile
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Installation abgeschlossen" `
|
||||||
|
-ForegroundColor Green
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
$ReportFile `
|
||||||
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
Write-ExceptionLog `
|
||||||
|
|
||||||
|
-Exception $_.Exception `
|
||||||
|
|
||||||
|
-Context "Main Installer"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Installation fehlgeschlagen" `
|
||||||
|
-ForegroundColor Red
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
}
|
||||||
|
#Begin PART 6
|
||||||
|
############################################################
|
||||||
|
# Abschluss
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
Write-EnterpriseLog `
|
||||||
|
|
||||||
|
-Level INFO `
|
||||||
|
|
||||||
|
-Message "Installer beendet"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-AuditEvent `
|
||||||
|
|
||||||
|
-Action "Installer beendet" `
|
||||||
|
|
||||||
|
-Status "SUCCESS"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Ende Install-VeeamEnterprise.ps1
|
||||||
|
############################################################
|
||||||
@@ -0,0 +1,595 @@
|
|||||||
|
<#
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
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.
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
if($PSScriptRoot)
|
||||||
|
{
|
||||||
|
Split-Path $PSScriptRoot -Parent
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Initialize-Paths
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Initialize-Paths {
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Initialisiert sämtliche Projektpfade.
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
$Script:RootPath =
|
||||||
|
Get-ProjectRoot
|
||||||
|
|
||||||
|
$Script:ModulePath =
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Modules"
|
||||||
|
|
||||||
|
$Script:ConfigPath =
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Config"
|
||||||
|
|
||||||
|
$Script:ResourcePath =
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Resources"
|
||||||
|
|
||||||
|
$Script:ReportPath =
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Reports"
|
||||||
|
|
||||||
|
$Script:LogPath =
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Logs"
|
||||||
|
|
||||||
|
$Script:TempPath =
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Temp"
|
||||||
|
|
||||||
|
$Script:LogFile =
|
||||||
|
Join-Path `
|
||||||
|
$LogPath `
|
||||||
|
"Install.log"
|
||||||
|
|
||||||
|
$Script:TranscriptFile =
|
||||||
|
Join-Path `
|
||||||
|
$LogPath `
|
||||||
|
"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 = @(
|
||||||
|
|
||||||
|
$ModulePath,
|
||||||
|
$ConfigPath,
|
||||||
|
$ResourcePath,
|
||||||
|
$ReportPath,
|
||||||
|
$LogPath,
|
||||||
|
$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."
|
||||||
|
}
|
||||||
|
|
||||||
|
if((Get-PowerShellVersion).Major -lt 5)
|
||||||
|
{
|
||||||
|
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
@@ -0,0 +1,645 @@
|
|||||||
|
<#
|
||||||
|
.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 =
|
||||||
|
|
||||||
|
"1.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Script:DryRunEnabled =
|
||||||
|
|
||||||
|
$true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get-DryRunStatus
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Get-DryRunStatus {
|
||||||
|
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Liefert Dry-Run Status.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
Enabled =
|
||||||
|
|
||||||
|
$Script:DryRunEnabled
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Mode =
|
||||||
|
|
||||||
|
"Simulation"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
[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(
|
||||||
|
|
||||||
|
[string]$SourcePath,
|
||||||
|
|
||||||
|
|
||||||
|
[string]$SQLServer,
|
||||||
|
|
||||||
|
|
||||||
|
[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(
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
|
||||||
|
[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(
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
|
||||||
|
[string]$Repository,
|
||||||
|
|
||||||
|
|
||||||
|
[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
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
$Results = @()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Results +=
|
||||||
|
|
||||||
|
Test-DryRunInstallation `
|
||||||
|
|
||||||
|
-SourcePath "Simulation"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Results +=
|
||||||
|
|
||||||
|
Test-DryRunRepository `
|
||||||
|
|
||||||
|
-Name $Configuration.RepositoryName `
|
||||||
|
|
||||||
|
-Path $Configuration.RepositoryPath
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Results +=
|
||||||
|
|
||||||
|
Test-DryRunBackupJob `
|
||||||
|
|
||||||
|
-Name $Configuration.BackupJobName `
|
||||||
|
|
||||||
|
-Repository $Configuration.RepositoryName `
|
||||||
|
|
||||||
|
-RetentionDays $Configuration.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 =
|
||||||
|
|
||||||
|
"C:\ProgramData\VeeamInstaller\Reports"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
RepositoryDefined =
|
||||||
|
|
||||||
|
(
|
||||||
|
![string]::IsNullOrWhiteSpace(
|
||||||
|
$Configuration.RepositoryPath
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DatabaseDefined =
|
||||||
|
|
||||||
|
(
|
||||||
|
![string]::IsNullOrWhiteSpace(
|
||||||
|
$Configuration.Database
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JobDefined =
|
||||||
|
|
||||||
|
(
|
||||||
|
![string]::IsNullOrWhiteSpace(
|
||||||
|
$Configuration.BackupJobName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Valid =
|
||||||
|
|
||||||
|
$true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
@@ -0,0 +1,561 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Prüft alle Veeam Installer Module.
|
||||||
|
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
|
||||||
|
- Syntaxprüfung
|
||||||
|
- Importprüfung
|
||||||
|
- Funktionsprüfung
|
||||||
|
- Fehlerreport
|
||||||
|
|
||||||
|
|
||||||
|
.VERSION
|
||||||
|
|
||||||
|
1.0.0
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
Set-StrictMode -Version Latest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Pfade
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
$RootPath =
|
||||||
|
|
||||||
|
Split-Path `
|
||||||
|
$PSScriptRoot
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ModulePath =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Modules"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ReportPath =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
$RootPath `
|
||||||
|
"Reports"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!(Test-Path $ReportPath))
|
||||||
|
{
|
||||||
|
|
||||||
|
New-Item `
|
||||||
|
|
||||||
|
-Path $ReportPath `
|
||||||
|
|
||||||
|
-ItemType Directory `
|
||||||
|
|
||||||
|
-Force |
|
||||||
|
|
||||||
|
Out-Null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Modul Liste
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
$Modules = @(
|
||||||
|
|
||||||
|
"Core\Logging.psm1",
|
||||||
|
|
||||||
|
"Core\Configuration.psm1",
|
||||||
|
|
||||||
|
"Core\Utilities.psm1",
|
||||||
|
|
||||||
|
"Core\Security.psm1",
|
||||||
|
|
||||||
|
"Core\SQL.psm1",
|
||||||
|
|
||||||
|
"Veeam\VeeamInstallation.psm1",
|
||||||
|
|
||||||
|
"Veeam\Repository.psm1",
|
||||||
|
|
||||||
|
"Veeam\BackupJobs.psm1"
|
||||||
|
|
||||||
|
)
|
||||||
|
#Beginn PART 2
|
||||||
|
############################################################
|
||||||
|
# Syntaxprüfung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Test-PowerShellSyntax {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[string]$File
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
$Result =
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
File =
|
||||||
|
|
||||||
|
$File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SyntaxOK =
|
||||||
|
|
||||||
|
$false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Error =
|
||||||
|
|
||||||
|
$null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
$Tokens = $null
|
||||||
|
|
||||||
|
$Errors = $null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[System.Management.Automation.Language.Parser]
|
||||||
|
::ParseFile(
|
||||||
|
|
||||||
|
$File,
|
||||||
|
|
||||||
|
[ref]$Tokens,
|
||||||
|
|
||||||
|
[ref]$Errors
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($Errors.Count -eq 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$Result.SyntaxOK = $true
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
$Result.Error =
|
||||||
|
|
||||||
|
$Errors.Exception.Message
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
$Result.Error =
|
||||||
|
|
||||||
|
$_.Exception.Message
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $Result
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Modul Import Prüfung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Test-ModuleImport {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[string]$File
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
$Result =
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
File =
|
||||||
|
|
||||||
|
$File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImportOK =
|
||||||
|
|
||||||
|
$false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Error =
|
||||||
|
|
||||||
|
$null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
Import-Module `
|
||||||
|
|
||||||
|
$File `
|
||||||
|
|
||||||
|
-Force `
|
||||||
|
|
||||||
|
-ErrorAction Stop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Result.ImportOK = $true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
$Result.Error =
|
||||||
|
|
||||||
|
$_.Exception.Message
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $Result
|
||||||
|
|
||||||
|
}
|
||||||
|
#Beginn PART 3
|
||||||
|
############################################################
|
||||||
|
# Alle Module prüfen
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Invoke-ModuleValidation {
|
||||||
|
|
||||||
|
|
||||||
|
$Results = @()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach($Module in $Modules)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$File =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
|
||||||
|
$ModulePath `
|
||||||
|
|
||||||
|
$Module
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!(Test-Path $File))
|
||||||
|
{
|
||||||
|
|
||||||
|
$Results += [PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
File =
|
||||||
|
|
||||||
|
$File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SyntaxOK =
|
||||||
|
|
||||||
|
$false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImportOK =
|
||||||
|
|
||||||
|
$false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Error =
|
||||||
|
|
||||||
|
"Datei nicht gefunden."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Syntax =
|
||||||
|
|
||||||
|
Test-PowerShellSyntax `
|
||||||
|
|
||||||
|
-File $File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Import =
|
||||||
|
|
||||||
|
Test-ModuleImport `
|
||||||
|
|
||||||
|
-File $File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Results += [PSCustomObject]@{
|
||||||
|
|
||||||
|
|
||||||
|
File =
|
||||||
|
|
||||||
|
$File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SyntaxOK =
|
||||||
|
|
||||||
|
$Syntax.SyntaxOK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImportOK =
|
||||||
|
|
||||||
|
$Import.ImportOK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Error =
|
||||||
|
|
||||||
|
if($Syntax.Error)
|
||||||
|
{
|
||||||
|
|
||||||
|
$Syntax.Error
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($Import.Error)
|
||||||
|
{
|
||||||
|
|
||||||
|
$Import.Error
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
$null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $Results
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Report erstellen
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
function Save-ModuleValidationReport {
|
||||||
|
|
||||||
|
|
||||||
|
param(
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
|
||||||
|
[array]$Results
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$File =
|
||||||
|
|
||||||
|
Join-Path `
|
||||||
|
|
||||||
|
$ReportPath `
|
||||||
|
|
||||||
|
(
|
||||||
|
"ModuleValidation_" +
|
||||||
|
|
||||||
|
(
|
||||||
|
Get-Date `
|
||||||
|
-Format "yyyyMMdd_HHmmss"
|
||||||
|
) +
|
||||||
|
|
||||||
|
".json"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Results |
|
||||||
|
|
||||||
|
ConvertTo-Json `
|
||||||
|
|
||||||
|
-Depth 5 |
|
||||||
|
|
||||||
|
Out-File `
|
||||||
|
|
||||||
|
-FilePath $File `
|
||||||
|
|
||||||
|
-Encoding UTF8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $File
|
||||||
|
|
||||||
|
}
|
||||||
|
#Beginn PART 4
|
||||||
|
############################################################
|
||||||
|
# Hauptausführung
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"======================================" `
|
||||||
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
" Veeam Modul Syntaxprüfung" `
|
||||||
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"======================================" `
|
||||||
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ValidationResults =
|
||||||
|
|
||||||
|
Invoke-ModuleValidation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ReportFile =
|
||||||
|
|
||||||
|
Save-ModuleValidationReport `
|
||||||
|
|
||||||
|
-Results $ValidationResults
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Prüfergebnis:" `
|
||||||
|
-ForegroundColor Yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach($Result in $ValidationResults)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(
|
||||||
|
$Result.SyntaxOK -and
|
||||||
|
$Result.ImportOK
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"[OK] $($Result.File)" `
|
||||||
|
-ForegroundColor Green
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"[FEHLER] $($Result.File)" `
|
||||||
|
-ForegroundColor Red
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
$Result.Error
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Report gespeichert:" `
|
||||||
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
|
Write-Host $ReportFile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$Failed =
|
||||||
|
|
||||||
|
$ValidationResults |
|
||||||
|
|
||||||
|
Where-Object {
|
||||||
|
|
||||||
|
(!$_.SyntaxOK) -or
|
||||||
|
(!$_.ImportOK)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($Failed.Count -gt 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user