Version 1.0.1
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
- Dry-Run Unterstützung
|
||||
|
||||
.VERSION
|
||||
1.0.0
|
||||
1.0.1
|
||||
#>
|
||||
|
||||
|
||||
@@ -59,13 +59,6 @@ $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"
|
||||
|
||||
if([string]::IsNullOrWhiteSpace($VeeamAnswerFile))
|
||||
{
|
||||
$VeeamAnswerFile = Join-Path (Join-Path $Script:InstallerRoot "Config") "VeeamAnswerFile.xml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
############################################################
|
||||
# Import Installer Module
|
||||
############################################################
|
||||
@@ -390,13 +383,44 @@ function Install-VeeamProduct {
|
||||
|
||||
|
||||
|
||||
return (
|
||||
|
||||
Invoke-VeeamInstallation `
|
||||
$InstallResult = Invoke-VeeamInstallation `
|
||||
-SourcePath $SourcePath `
|
||||
-AnswerFile $AnswerFile
|
||||
-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
|
||||
|
||||
}
|
||||
|
||||
@@ -447,6 +471,62 @@ function Initialize-BackupRepository {
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
@@ -542,8 +622,7 @@ function Start-VeeamEnterpriseInstall {
|
||||
[string]$VeeamSourcePath,
|
||||
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
|
||||
[AllowEmptyString()]
|
||||
[string]$VeeamAnswerFile
|
||||
|
||||
)
|
||||
@@ -560,6 +639,10 @@ function Start-VeeamEnterpriseInstall {
|
||||
-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)
|
||||
@@ -611,7 +694,42 @@ function Start-VeeamEnterpriseInstall {
|
||||
else
|
||||
{
|
||||
|
||||
$SQLCheck = Test-InstallerSQL -Configuration $Configuration
|
||||
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 `
|
||||
@@ -620,6 +738,14 @@ function Start-VeeamEnterpriseInstall {
|
||||
-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
|
||||
@@ -857,6 +983,19 @@ if($Script:IsDryRun)
|
||||
|
||||
}
|
||||
|
||||
$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
|
||||
|
||||
Reference in New Issue
Block a user