1057 lines
22 KiB
PowerShell
1057 lines
22 KiB
PowerShell
<#
|
|
.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.2
|
|
#>
|
|
|
|
|
|
############################################################
|
|
# Script Parameter
|
|
############################################################
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
|
|
[AllowEmptyString()]
|
|
[string]$VeeamSourcePath,
|
|
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
|
|
[string]$VeeamAnswerFile,
|
|
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
|
|
[switch]$DryRun
|
|
|
|
)
|
|
|
|
|
|
Set-StrictMode -Version Latest
|
|
|
|
|
|
|
|
############################################################
|
|
# Globale Variablen
|
|
############################################################
|
|
############################################################
|
|
# Globale Zustände
|
|
############################################################
|
|
|
|
$Script:IsDryRun = $DryRun.IsPresent
|
|
|
|
$Script:InstallerRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
$Script:ModulePath = Join-Path $Script:InstallerRoot "Modules"
|
|
$Script:ConfigPath = Join-Path (Join-Path $Script:InstallerRoot "Config") "VeeamConfig.json"
|
|
|
|
############################################################
|
|
# Import Installer Module
|
|
############################################################
|
|
|
|
function Import-InstallerModules {
|
|
|
|
|
|
$Modules = @(
|
|
"Core\Bootstrap.psm1",
|
|
"Core\Utilities.psm1",
|
|
"Core\Logging.psm1",
|
|
"Core\Configuration.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)
|
|
{
|
|
|
|
Write-Host "Lade Modul: $Path" -ForegroundColor Cyan
|
|
|
|
Import-Module `
|
|
$Path `
|
|
-Force `
|
|
-Verbose `
|
|
-ErrorAction Stop
|
|
|
|
}
|
|
else
|
|
{
|
|
throw "Modul nicht gefunden: $Path"
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
#Begin PART 2
|
|
############################################################
|
|
# Installer Initialisierung
|
|
############################################################
|
|
|
|
function Initialize-Installer {
|
|
|
|
|
|
Write-Host ""
|
|
Write-Host "Initialisiere Veeam Enterprise Installer..." -ForegroundColor Cyan
|
|
|
|
|
|
Write-Host "1 - Module laden"
|
|
|
|
try
|
|
{
|
|
Import-InstallerModules
|
|
|
|
Write-Host "2 - Module erfolgreich geladen." -ForegroundColor Green
|
|
|
|
Write-Host "3 - Admin Prüfung"
|
|
Test-AdministratorRights
|
|
}
|
|
catch
|
|
{
|
|
Write-Host ""
|
|
Write-Host "FEHLER BEIM MODULLADEN:" -ForegroundColor Red
|
|
Write-Host $_.Exception.Message -ForegroundColor Red
|
|
Write-Host $_.InvocationInfo.PositionMessage -ForegroundColor Yellow
|
|
|
|
throw
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
############################################################
|
|
# 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 {
|
|
|
|
|
|
Write-Host ""
|
|
Write-Host "Lade Veeam Konfiguration..." -ForegroundColor Yellow
|
|
|
|
|
|
Import-VeeamConfiguration `
|
|
-Path $Script:ConfigPath |
|
|
Out-Null
|
|
|
|
|
|
$Config = Get-Configuration
|
|
|
|
|
|
if($null -eq $Config)
|
|
{
|
|
throw "Keine Konfiguration geladen."
|
|
}
|
|
|
|
|
|
if([string]$Config.SQL.Server -eq "Auto")
|
|
{
|
|
if([string]::IsNullOrWhiteSpace($env:COMPUTERNAME))
|
|
{
|
|
throw "Der lokale Windows-Hostname konnte nicht ermittelt werden."
|
|
}
|
|
|
|
$Config.SQL.Server = $env:COMPUTERNAME
|
|
}
|
|
|
|
|
|
$Validation =
|
|
Test-VeeamConfiguration `
|
|
-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,
|
|
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$AnswerFile
|
|
|
|
)
|
|
|
|
|
|
|
|
Write-Host ""
|
|
|
|
Write-Host `
|
|
"Installiere Veeam..." `
|
|
-ForegroundColor Yellow
|
|
|
|
|
|
|
|
if($Script:IsDryRun)
|
|
{
|
|
|
|
return (
|
|
|
|
Test-DryRunInstallation -SourcePath $SourcePath -SQLServer $Configuration.SQL.Server -Database $Configuration.SQL.Database
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
$InstallResult = Invoke-VeeamInstallation `
|
|
-SourcePath $SourcePath `
|
|
-AnswerFile $AnswerFile `
|
|
-SkipNetworkLogonErrors
|
|
|
|
|
|
if(
|
|
$null -eq $InstallResult -or
|
|
$null -eq $InstallResult.Result -or
|
|
!$InstallResult.Result.Successful
|
|
)
|
|
{
|
|
$ExitCode = $null
|
|
$LogFile = $null
|
|
|
|
if($null -ne $InstallResult -and $null -ne $InstallResult.Result)
|
|
{
|
|
$ExitCode = $InstallResult.Result.ExitCode
|
|
$LogFile = $InstallResult.Result.LogFile
|
|
}
|
|
|
|
$DetailLogFolder = $null
|
|
if($null -ne $InstallResult)
|
|
{
|
|
$DetailLogFolder = $InstallResult.LogFolder
|
|
}
|
|
|
|
throw "Veeam-Installation fehlgeschlagen. ExitCode: $ExitCode; Launcher-Log: $LogFile; Veeam-Logs: $DetailLogFolder"
|
|
}
|
|
|
|
|
|
if($InstallResult.Result.RebootRequired)
|
|
{
|
|
throw "Veeam-Installation war erfolgreich, benötigt aber einen Neustart. Repository-Konfiguration wurde noch nicht gestartet."
|
|
}
|
|
|
|
|
|
return $InstallResult
|
|
|
|
}
|
|
|
|
|
|
|
|
############################################################
|
|
# Repository Initialisierung
|
|
############################################################
|
|
|
|
function Initialize-BackupRepository {
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[PSCustomObject]$Configuration
|
|
|
|
)
|
|
|
|
|
|
|
|
Write-Host ""
|
|
|
|
Write-Host `
|
|
"Erstelle Repository..." `
|
|
-ForegroundColor Yellow
|
|
|
|
|
|
|
|
if($Script:IsDryRun)
|
|
{
|
|
|
|
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
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Temporäres lokales Veeam-Administratorkonto
|
|
############################################################
|
|
|
|
function New-LocalVeeamAdministrator {
|
|
$UserName = "VEEAM"
|
|
$PlainPassword = "P@ssw0rd1234."
|
|
|
|
if($Script:IsDryRun) {
|
|
return [PSCustomObject]@{
|
|
UserName = ".\$UserName"
|
|
Password = "Wird im Dry-Run nicht gesetzt"
|
|
Created = $false
|
|
}
|
|
}
|
|
|
|
if(!(Get-Command New-LocalUser -ErrorAction SilentlyContinue)) {
|
|
throw "New-LocalUser ist auf diesem System nicht verfügbar. Das lokale Veeam-Administratorkonto konnte nicht erstellt werden."
|
|
}
|
|
|
|
$SecurePassword = ConvertTo-SecureString -String $PlainPassword -AsPlainText -Force
|
|
$ExistingUser = Get-LocalUser -Name $UserName -ErrorAction SilentlyContinue
|
|
if($null -eq $ExistingUser) {
|
|
New-LocalUser `
|
|
-Name $UserName `
|
|
-Password $SecurePassword `
|
|
-Description "Temporäres Veeam-Initialisierungskonto" `
|
|
-PasswordNeverExpires:$true `
|
|
-UserMayNotChangePassword:$false `
|
|
-AccountNeverExpires | Out-Null
|
|
}
|
|
else {
|
|
Set-LocalUser -Name $UserName -Password $SecurePassword -PasswordNeverExpires $true
|
|
Enable-LocalUser -Name $UserName
|
|
}
|
|
|
|
$AdministratorsGroup = ([Security.Principal.SecurityIdentifier]"S-1-5-32-544").Translate([Security.Principal.NTAccount]).Value.Split("\")[-1]
|
|
if(-not (Get-LocalGroupMember -Group $AdministratorsGroup -Member $UserName -ErrorAction SilentlyContinue)) {
|
|
Add-LocalGroupMember -Group $AdministratorsGroup -Member $UserName -ErrorAction Stop
|
|
}
|
|
|
|
$VeeamGroup = Get-LocalGroup -Name "Veeam Backup Administrators" -ErrorAction SilentlyContinue
|
|
if($null -ne $VeeamGroup) {
|
|
if(-not (Get-LocalGroupMember -Group $VeeamGroup.Name -Member $UserName -ErrorAction SilentlyContinue)) {
|
|
Add-LocalGroupMember -Group $VeeamGroup.Name -Member $UserName -ErrorAction Stop
|
|
}
|
|
}
|
|
|
|
return [PSCustomObject]@{
|
|
UserName = ".\$UserName"
|
|
Password = $PlainPassword
|
|
Created = $true
|
|
}
|
|
}
|
|
#Begin PART 4
|
|
############################################################
|
|
# Backup Job Initialisierung
|
|
############################################################
|
|
|
|
function Initialize-BackupJobs
|
|
{
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[PSCustomObject]$Configuration
|
|
|
|
)
|
|
|
|
Write-Host ""
|
|
|
|
Write-Host `
|
|
"Erstelle Backup Jobs..." `
|
|
-ForegroundColor Yellow
|
|
|
|
|
|
|
|
if($Script:IsDryRun)
|
|
{
|
|
|
|
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
|
|
|
|
$AlphabeticalSchedules = New-AlphabeticalBackupSchedules `
|
|
-JobName $Configuration.BackupJob.Name `
|
|
-VirtualMachines @($Configuration.BackupJob.Objects) `
|
|
-ScheduleGroups @($Configuration.BackupJob.ScheduleGroups)
|
|
|
|
$Deployment = Deploy-BackupJobDefinition -Job $Job
|
|
|
|
if(!$Deployment.DeploymentReady)
|
|
{
|
|
throw $Deployment.Reason
|
|
}
|
|
|
|
|
|
|
|
return [PSCustomObject]@{
|
|
|
|
|
|
Job = $Job
|
|
|
|
Schedule = $Schedule
|
|
|
|
ApplicationAware = $ApplicationAware
|
|
|
|
AlphabeticalSchedules = $AlphabeticalSchedules
|
|
|
|
Deployment = $Deployment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
############################################################
|
|
# Haupt Installationsablauf
|
|
############################################################
|
|
|
|
function Start-VeeamEnterpriseInstall {
|
|
|
|
|
|
param(
|
|
|
|
[AllowEmptyString()]
|
|
[string]$VeeamSourcePath,
|
|
|
|
|
|
[AllowEmptyString()]
|
|
[string]$VeeamAnswerFile
|
|
|
|
)
|
|
|
|
|
|
|
|
try
|
|
{
|
|
|
|
|
|
$Configuration = Get-InstallerConfiguration
|
|
|
|
$VeeamSourcePath = Resolve-VeeamSourcePath `
|
|
-SourcePath $VeeamSourcePath `
|
|
-ConfiguredPath ([string]$Configuration.Veeam.SourcePath)
|
|
|
|
$Configuration.Repository.Path = Resolve-RepositoryPath `
|
|
-Path ([string]$Configuration.Repository.Path) `
|
|
-InstallationSource $VeeamSourcePath
|
|
|
|
$SystemCheck = Test-InstallerPrerequisites
|
|
|
|
if($Script:IsDryRun)
|
|
{
|
|
|
|
Write-Host ""
|
|
Write-Host "DRY-RUN aktiviert" -ForegroundColor Yellow
|
|
|
|
|
|
$SQLCheck = [PSCustomObject]@{
|
|
Server = $Configuration.SQL.Server
|
|
Instance = $Configuration.SQL.Instance
|
|
Database = $Configuration.SQL.Database
|
|
ConnectionTested = $false
|
|
Status = "DryRunOnly"
|
|
}
|
|
|
|
|
|
$Installation =
|
|
Test-DryRunInstallation `
|
|
-SourcePath $VeeamSourcePath `
|
|
-SQLServer $Configuration.SQL.Server `
|
|
-Database $Configuration.SQL.Database
|
|
|
|
|
|
$Repository =
|
|
Test-DryRunRepository `
|
|
-Name $Configuration.Repository.Name `
|
|
-Path $Configuration.Repository.Path
|
|
|
|
|
|
$JobSimulation =
|
|
Test-DryRunBackupJob `
|
|
-Name $Configuration.BackupJob.Name `
|
|
-Repository $Configuration.Repository.Name `
|
|
-RetentionDays $Configuration.Repository.RetentionDays
|
|
|
|
$AlphabeticalSchedules = New-AlphabeticalBackupSchedules `
|
|
-JobName $Configuration.BackupJob.Name `
|
|
-VirtualMachines @($Configuration.BackupJob.Objects) `
|
|
-ScheduleGroups @($Configuration.BackupJob.ScheduleGroups)
|
|
|
|
$Jobs = [PSCustomObject]@{
|
|
Simulation = $JobSimulation
|
|
AlphabeticalSchedules = $AlphabeticalSchedules
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
if(
|
|
$Configuration.SQL.Engine -eq "PostgreSQL" -and
|
|
$Configuration.SQL.InstallNew
|
|
)
|
|
{
|
|
$SQLCheck = [PSCustomObject]@{
|
|
Engine = "PostgreSQL"
|
|
Server = "localhost:5432"
|
|
Database = $Configuration.SQL.Database
|
|
ConnectionTested = $false
|
|
Status = "WillBeInstalledByVeeam"
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$SQLCheck = Test-InstallerSQL -Configuration $Configuration
|
|
|
|
Write-Host "Bereite Veeam-Datenbank und LocalSystem-Berechtigung vor..." -ForegroundColor Yellow
|
|
$SQLPreparation = Initialize-VeeamSQLDatabase `
|
|
-Server $Configuration.SQL.Server `
|
|
-Instance $Configuration.SQL.Instance `
|
|
-Database $Configuration.SQL.Database
|
|
|
|
Write-EnterpriseLog `
|
|
-Level INFO `
|
|
-Message ("SQL-Datenbank vorbereitet: {0}; Konto: {1}; Rolle: {2}" -f $SQLPreparation.Database, $SQLPreparation.ServiceAccount, $SQLPreparation.DatabaseRole)
|
|
}
|
|
|
|
$VeeamAnswerFile = Resolve-VeeamAnswerFile `
|
|
-AnswerFile $VeeamAnswerFile `
|
|
-SourcePath $VeeamSourcePath `
|
|
-LocalConfigPath (Join-Path $Script:InstallerRoot "Config") `
|
|
-DatabaseEngine $Configuration.SQL.Engine `
|
|
-SQLServer $Configuration.SQL.Server `
|
|
-SQLInstance $Configuration.SQL.Instance `
|
|
-DatabaseName $Configuration.SQL.Database
|
|
|
|
$Installation =
|
|
Install-VeeamProduct `
|
|
-Configuration $Configuration `
|
|
-SourcePath $VeeamSourcePath `
|
|
-AnswerFile $VeeamAnswerFile
|
|
|
|
|
|
if($null -eq (Get-Module -ListAvailable -Name "Veeam.Backup.PowerShell"))
|
|
{
|
|
throw "Veeam wurde installiert, aber Veeam.Backup.PowerShell ist noch nicht verfügbar. Neustart oder neue PowerShell-Sitzung erforderlich."
|
|
}
|
|
|
|
Import-Module "Veeam.Backup.PowerShell" -Force -ErrorAction Stop
|
|
|
|
|
|
$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($Script:IsDryRun)
|
|
{
|
|
|
|
"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" |
|
|
Out-Null
|
|
|
|
|
|
Write-EnterpriseLog `
|
|
-Level INFO `
|
|
-Message "Logging initialisiert"
|
|
|
|
|
|
Write-EnterpriseLog `
|
|
-Level INFO `
|
|
-Message "Installer gestartet"
|
|
|
|
if($Script:IsDryRun)
|
|
{
|
|
|
|
Enable-DryRunMode | Out-Null
|
|
|
|
Write-EnterpriseLog `
|
|
-Level INFO `
|
|
-Message "DryRun aktiviert"
|
|
|
|
}
|
|
|
|
$VeeamAdmin = New-LocalVeeamAdministrator
|
|
|
|
if($VeeamAdmin.Created) {
|
|
Write-EnterpriseLog -Level INFO -Message ("Lokales Veeam-Administratorkonto erstellt: {0}" -f $VeeamAdmin.UserName)
|
|
Write-EnterpriseLog -Level WARNING -Message ("Temporäres Kennwort: {0}" -f $VeeamAdmin.Password)
|
|
Write-EnterpriseLog -Level WARNING -Message "Nach der Veeam-Erstinitialisierung muss das temporäre Konto manuell gelöscht werden: Remove-LocalUser -Name 'VEEAM'"
|
|
|
|
Write-Host ""
|
|
Write-Host "Lokales Veeam-Administratorkonto: $($VeeamAdmin.UserName)" -ForegroundColor Cyan
|
|
Write-Host "Temporäres Kennwort: $($VeeamAdmin.Password)" -ForegroundColor Yellow
|
|
Write-Host "Nach der Erstinitialisierung löschen: Remove-LocalUser -Name 'VEEAM'" -ForegroundColor Yellow
|
|
}
|
|
|
|
$Result = Start-VeeamEnterpriseInstall `
|
|
-VeeamSourcePath $VeeamSourcePath `
|
|
-VeeamAnswerFile $VeeamAnswerFile
|
|
|
|
$Report = Get-EnterpriseInstallationReport -Result $Result
|
|
|
|
$ReportFile = Save-EnterpriseReport -Report $Report
|
|
|
|
|
|
|
|
$InstallMessage = "Installation abgeschlossen"
|
|
|
|
Write-EnterpriseLog `
|
|
-Level INFO `
|
|
-Message $InstallMessage
|
|
|
|
|
|
|
|
Write-Host ""
|
|
|
|
Write-Host `
|
|
"Installation abgeschlossen" `
|
|
-ForegroundColor Green
|
|
|
|
|
|
|
|
Write-Host `
|
|
$ReportFile `
|
|
-ForegroundColor Cyan
|
|
|
|
|
|
}
|
|
catch
|
|
{
|
|
if(Get-Command Write-ExceptionLog -ErrorAction SilentlyContinue)
|
|
{
|
|
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
|
|
############################################################
|