615 lines
8.8 KiB
PowerShell
Executable File
615 lines
8.8 KiB
PowerShell
Executable File
#Requires -RunAsAdministrator
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# CLEAN INSTALL
|
|
$Pfad = "C:\Temp\VeeamInstall"
|
|
|
|
if (Test-Path $Pfad) {
|
|
try {
|
|
Remove-Item -Path $Pfad -Recurse -Force -ErrorAction Stop
|
|
Write-Host "Alte VeeamInstall-Dateien entfernt."
|
|
}
|
|
catch {
|
|
Write-Host "Fehler beim Löschen: $_"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Weiter mit Installation
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Unattended Installation Veeam Backup & Replication v13
|
|
|
|
.DESCRIPTION
|
|
Installation von Veeam Backup & Replication v13
|
|
mit vorhandener Microsoft SQL Server 2019 Instanz.
|
|
|
|
Quelle:
|
|
DVD oder Netzwerkquelle
|
|
|
|
Datenbank:
|
|
<Servername>\VEEAMSQLSERVER
|
|
|
|
#>
|
|
|
|
|
|
############################################################
|
|
# VARIABLEN
|
|
############################################################
|
|
|
|
# Quelle DVD
|
|
$DVDSource = "E:\"
|
|
|
|
|
|
# Quelle Netzwerk
|
|
$NetworkSource = "\\172.68.1.1\Sources"
|
|
|
|
|
|
|
|
############################################################
|
|
# INSTALLATIONSQUELLE AUSWÄHLEN
|
|
############################################################
|
|
|
|
Write-Host ""
|
|
Write-Host "Veeam Installationsquelle"
|
|
Write-Host "========================="
|
|
Write-Host "1 = DVD / ISO Quelle ($DVDSource)"
|
|
Write-Host "2 = Netzwerkquelle ($NetworkSource)"
|
|
Write-Host ""
|
|
|
|
|
|
$SourceChoice = Read-Host "Quelle auswählen (1 oder 2)"
|
|
|
|
|
|
switch ($SourceChoice)
|
|
{
|
|
|
|
"1"
|
|
{
|
|
|
|
$VeeamSource = $DVDSource
|
|
|
|
Write-Host ""
|
|
Write-Host "Lokale Quelle gewählt:"
|
|
Write-Host $VeeamSource
|
|
|
|
}
|
|
|
|
|
|
"2"
|
|
{
|
|
|
|
$VeeamSource = $NetworkSource
|
|
|
|
|
|
Write-Host ""
|
|
Write-Host "Anmeldung an Netzwerkquelle"
|
|
|
|
|
|
$Credential = Get-Credential
|
|
|
|
|
|
|
|
New-PSDrive `
|
|
-Name "VEEAMSRC" `
|
|
-PSProvider FileSystem `
|
|
-Root $VeeamSource `
|
|
-Credential $Credential `
|
|
-ErrorAction Stop | Out-Null
|
|
|
|
|
|
|
|
$VeeamSource = "VEEAMSRC:\"
|
|
|
|
|
|
Write-Host ""
|
|
Write-Host "Netzwerkquelle verbunden:"
|
|
Write-Host $VeeamSource
|
|
|
|
}
|
|
|
|
|
|
default
|
|
{
|
|
|
|
Write-Host "Ungültige Auswahl"
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Installer
|
|
$VeeamInstaller = `
|
|
"$VeeamSource\Setup\Silent\Veeam.Silent.Install.exe"
|
|
|
|
|
|
# Antwortdatei
|
|
$AnswerFileSource = `
|
|
"$VeeamSource\Setup\Silent\AnswerFiles\VBR\VbrAnswerFile_install.xml"
|
|
|
|
|
|
|
|
# Arbeitsverzeichnis lokal
|
|
$WorkDir = "C:\Temp\VeeamInstall"
|
|
|
|
$LogDir = "$WorkDir\Logs"
|
|
|
|
|
|
|
|
# Lizenz
|
|
$LicenseSource = "$VeeamSource\License\veeam.lic"
|
|
|
|
$LicenseTarget = "$WorkDir\veeam.lic"
|
|
|
|
|
|
|
|
# Servername
|
|
$VeeamServerName = $env:COMPUTERNAME
|
|
|
|
|
|
|
|
# SQL Server
|
|
$SQLServerName = $VeeamServerName
|
|
|
|
$SQLInstanceName = "VEEAMSQLSERVER"
|
|
|
|
|
|
$SQLConnection = `
|
|
"$SQLServerName\$SQLInstanceName"
|
|
|
|
|
|
|
|
# SQL Datenbank
|
|
$DatabaseName = "VeeamBackup"
|
|
|
|
|
|
# 0 = Windows Authentication
|
|
$SQLAuthentication = 0
|
|
|
|
|
|
|
|
# Installationspfade
|
|
|
|
$InstallPath = "F:\Program Files\Veeam\Backup and Replication"
|
|
|
|
|
|
$CatalogPath = "H:\VBRCatalog"
|
|
|
|
|
|
$IRCachePath = "F:\ProgramData\Veeam\Backup\IRCache"
|
|
|
|
|
|
|
|
# Ports
|
|
|
|
$GuestCatalogPort = 9393
|
|
|
|
$VeeamServicePort = 9392
|
|
|
|
$SecureConnectionPort = 9401
|
|
|
|
$RestServicePort = 9419
|
|
|
|
|
|
|
|
# Plugins deaktivieren
|
|
|
|
$Plugins = @{
|
|
"AHV_INSTALL" = 0
|
|
"KVM_INSTALL" = 0
|
|
"PVE_INSTALL" = 0
|
|
"SCP_INSTALL" = 0
|
|
"AWS_INSTALL" = 0
|
|
"AZURE_INSTALL" = 0
|
|
"GCP_INSTALL" = 0
|
|
"KASTEN_INSTALL" = 0
|
|
}
|
|
|
|
|
|
|
|
# Neustart nicht automatisch
|
|
|
|
$RebootRequired = 0
|
|
|
|
|
|
|
|
############################################################
|
|
# FUNKTIONEN
|
|
############################################################
|
|
|
|
function Write-Log {
|
|
|
|
param(
|
|
[string]$Message
|
|
)
|
|
|
|
$Time = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
|
|
"$Time - $Message" |
|
|
Tee-Object `
|
|
-FilePath "$LogDir\Install.log" `
|
|
-Append
|
|
|
|
}
|
|
|
|
|
|
|
|
############################################################
|
|
# START
|
|
############################################################
|
|
|
|
|
|
############################################################
|
|
# Verzeichnisse
|
|
############################################################
|
|
|
|
New-Item `
|
|
$WorkDir `
|
|
-ItemType Directory `
|
|
-Force | Out-Null
|
|
|
|
|
|
New-Item `
|
|
$LogDir `
|
|
-ItemType Directory `
|
|
-Force | Out-Null
|
|
|
|
|
|
|
|
Write-Log "==== Veeam v13 Installation gestartet ===="
|
|
|
|
|
|
|
|
############################################################
|
|
# Quelle prüfen
|
|
############################################################
|
|
|
|
if (!(Test-Path $VeeamInstaller)) {
|
|
|
|
Write-Log "FEHLER: Installer nicht gefunden"
|
|
|
|
exit 1
|
|
}
|
|
|
|
|
|
Write-Log "Installationsquelle OK"
|
|
|
|
|
|
|
|
############################################################
|
|
# LIZENZ PRÜFEN
|
|
############################################################
|
|
|
|
$UseLicenseFile = $false
|
|
|
|
|
|
if(Test-Path $LicenseSource)
|
|
{
|
|
|
|
Copy-Item `
|
|
$LicenseSource `
|
|
$LicenseTarget `
|
|
-Force
|
|
|
|
|
|
$UseLicenseFile = $true
|
|
|
|
Write-Log "Lizenzdatei gefunden: $LicenseTarget"
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
Write-Log "Keine Lizenzdatei gefunden."
|
|
Write-Log "Installation wird als Community Edition durchgeführt."
|
|
|
|
}
|
|
############################################################
|
|
# Antwortdatei kopieren
|
|
############################################################
|
|
|
|
$AnswerFile = `
|
|
"$WorkDir\VbrAnswerFile_install.xml"
|
|
|
|
|
|
|
|
if(Test-Path $AnswerFile)
|
|
{
|
|
attrib -R $AnswerFile
|
|
icacls $AnswerFile /grant Administrators:F /T | Out-Null
|
|
Write-Log "Antwortdatei Schreibrechte gesetzt"
|
|
}
|
|
|
|
|
|
|
|
Copy-Item `
|
|
$AnswerFileSource `
|
|
$AnswerFile `
|
|
-Force
|
|
|
|
|
|
|
|
############################################################
|
|
# XML bearbeiten
|
|
############################################################
|
|
|
|
Write-Log "Passe Antwortdatei an"
|
|
|
|
|
|
|
|
[xml]$XML = Get-Content $AnswerFile
|
|
|
|
|
|
|
|
foreach($Property in `
|
|
$XML.unattendedInstallationConfiguration.properties.property)
|
|
{
|
|
|
|
|
|
switch($Property.name)
|
|
{
|
|
|
|
"ACCEPT_EULA"
|
|
{
|
|
$Property.value="1"
|
|
}
|
|
|
|
|
|
"ACCEPT_LICENSING_POLICY"
|
|
{
|
|
$Property.value="1"
|
|
}
|
|
|
|
|
|
"ACCEPT_THIRDPARTY_LICENSES"
|
|
{
|
|
$Property.value="1"
|
|
}
|
|
|
|
|
|
"ACCEPT_REQUIRED_SOFTWARE"
|
|
{
|
|
$Property.value="1"
|
|
}
|
|
|
|
|
|
|
|
"VBR_LICENSE_FILE"
|
|
{
|
|
if($UseLicenseFile)
|
|
{
|
|
$Property.value=$LicenseTarget
|
|
}
|
|
else
|
|
{
|
|
$Property.value="0"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
"VBR_SQLSERVER_INSTALL"
|
|
{
|
|
$Property.value="0"
|
|
}
|
|
|
|
|
|
|
|
"VBR_SQLSERVER_ENGINE"
|
|
{
|
|
$Property.value="0"
|
|
}
|
|
|
|
|
|
|
|
"VBR_SQLSERVER_SERVER"
|
|
{
|
|
$Property.value=$SQLConnection
|
|
}
|
|
|
|
|
|
|
|
"VBR_SQLSERVER_DATABASE"
|
|
{
|
|
$Property.value=$DatabaseName
|
|
}
|
|
|
|
|
|
|
|
"VBR_SQLSERVER_AUTHENTICATION"
|
|
{
|
|
$Property.value="$SQLAuthentication"
|
|
}
|
|
|
|
|
|
|
|
"VBR_ENTRAID_DATABASE_INSTALL"
|
|
{
|
|
$Property.value="0"
|
|
}
|
|
|
|
|
|
|
|
"INSTALLDIR"
|
|
{
|
|
$Property.value=$InstallPath
|
|
}
|
|
|
|
|
|
|
|
"VM_CATALOGPATH"
|
|
{
|
|
$Property.value=$CatalogPath
|
|
}
|
|
|
|
|
|
|
|
"VBR_IRCACHE"
|
|
{
|
|
$Property.value=$IRCachePath
|
|
}
|
|
|
|
|
|
|
|
"VBRC_SERVICE_PORT"
|
|
{
|
|
$Property.value="$GuestCatalogPort"
|
|
}
|
|
|
|
|
|
|
|
"VBR_SERVICE_PORT"
|
|
{
|
|
$Property.value="$VeeamServicePort"
|
|
}
|
|
|
|
|
|
|
|
"VBR_SECURE_CONNECTIONS_PORT"
|
|
{
|
|
$Property.value="$SecureConnectionPort"
|
|
}
|
|
|
|
|
|
|
|
"VBR_RESTSERVICE_PORT"
|
|
{
|
|
$Property.value="$RestServicePort"
|
|
}
|
|
|
|
|
|
|
|
"REBOOT_IF_REQUIRED"
|
|
{
|
|
$Property.value="$RebootRequired"
|
|
}
|
|
|
|
|
|
|
|
default
|
|
{
|
|
if($Plugins.ContainsKey($Property.name))
|
|
{
|
|
$Property.value="$($Plugins[$Property.name])"
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if(!(Test-Path $AnswerFile))
|
|
{
|
|
Write-Log "FEHLER: Antwortdatei existiert nicht"
|
|
exit 1
|
|
}
|
|
|
|
|
|
if(!(Get-Item $AnswerFile).IsReadOnly -eq $false)
|
|
{
|
|
Write-Log "FEHLER: Antwortdatei ist schreibgeschützt"
|
|
exit 1
|
|
}
|
|
|
|
|
|
Write-Log "Speichere angepasste Antwortdatei"
|
|
|
|
$XML.Save($AnswerFile)
|
|
|
|
Write-Log "Antwortdatei erfolgreich gespeichert"
|
|
|
|
|
|
$XML.Save($AnswerFile)
|
|
|
|
|
|
|
|
############################################################
|
|
# Installation
|
|
############################################################
|
|
|
|
Write-Log "Starte Veeam Installation"
|
|
|
|
|
|
|
|
$Arguments = @(
|
|
"/AnswerFile"
|
|
"`"$AnswerFile`""
|
|
"/SkipNetworkLogonErrors"
|
|
)
|
|
|
|
|
|
|
|
$Process = Start-Process `
|
|
-FilePath $VeeamInstaller `
|
|
-ArgumentList $Arguments `
|
|
-Wait `
|
|
-PassThru
|
|
|
|
|
|
|
|
############################################################
|
|
# Ergebnis
|
|
############################################################
|
|
|
|
Write-Log `
|
|
"Installer ExitCode: $($Process.ExitCode)"
|
|
|
|
|
|
|
|
switch($Process.ExitCode)
|
|
{
|
|
|
|
|
|
0
|
|
{
|
|
|
|
Write-Log `
|
|
"Installation erfolgreich"
|
|
|
|
}
|
|
|
|
|
|
|
|
3010
|
|
{
|
|
|
|
Write-Log `
|
|
"Installation erfolgreich - Neustart erforderlich"
|
|
|
|
}
|
|
|
|
|
|
|
|
default
|
|
{
|
|
|
|
Write-Log `
|
|
"Installation FEHLGESCHLAGEN"
|
|
|
|
exit $Process.ExitCode
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Log `
|
|
"==== Veeam Installation beendet ===="
|
|
|
|
|
|
|
|
Write-Host ""
|
|
Write-Host "Installation abgeschlossen."
|
|
Write-Host "Log:"
|
|
Write-Host "$LogDir\Install.log"
|