Initialer Import der Synology Scripts
This commit is contained in:
Executable
+220
@@ -0,0 +1,220 @@
|
||||
############################################################
|
||||
# PART 6.1
|
||||
#
|
||||
# AnswerFile kopieren
|
||||
############################################################
|
||||
|
||||
function Copy-AnswerFile {
|
||||
|
||||
Write-Log "Kopiere Antwortdatei"
|
||||
|
||||
$Script:AnswerFile = Join-Path `
|
||||
$WorkDir `
|
||||
"VbrAnswerFile_install.xml"
|
||||
|
||||
if(Test-Path $AnswerFile)
|
||||
{
|
||||
Remove-Item `
|
||||
$AnswerFile `
|
||||
-Force
|
||||
}
|
||||
|
||||
Copy-Item `
|
||||
-Path $AnswerFileSource `
|
||||
-Destination $AnswerFile `
|
||||
-Force
|
||||
|
||||
if(!(Test-Path $AnswerFile))
|
||||
{
|
||||
Stop-Installation "Antwortdatei konnte nicht kopiert werden."
|
||||
}
|
||||
|
||||
attrib -R $AnswerFile
|
||||
|
||||
Write-Log "Antwortdatei erfolgreich kopiert"
|
||||
|
||||
}
|
||||
############################################################
|
||||
# PART 6.2
|
||||
#
|
||||
# Part 6.2 – XML laden
|
||||
############################################################
|
||||
|
||||
function Open-AnswerFile {
|
||||
|
||||
Write-Log "Lade XML"
|
||||
|
||||
try
|
||||
{
|
||||
[xml]$Script:AnswerXML =
|
||||
Get-Content `
|
||||
$AnswerFile `
|
||||
-Encoding UTF8
|
||||
}
|
||||
catch
|
||||
{
|
||||
Stop-Installation "XML konnte nicht geladen werden."
|
||||
}
|
||||
|
||||
}
|
||||
############################################################
|
||||
# PART 6.3
|
||||
#
|
||||
# Part 6.3 – XML-Eigenschaft setzen
|
||||
############################################################
|
||||
|
||||
function Set-VBRProperty {
|
||||
|
||||
param(
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Name,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Value
|
||||
|
||||
)
|
||||
|
||||
$Node = $AnswerXML.
|
||||
unattendedInstallationConfiguration.
|
||||
properties.
|
||||
property |
|
||||
Where-Object Name -eq $Name
|
||||
|
||||
if(!$Node)
|
||||
{
|
||||
Write-Log "XML Property $Name nicht gefunden."
|
||||
return
|
||||
}
|
||||
|
||||
$Node.value = $Value
|
||||
|
||||
Write-Log "$Name = $Value"
|
||||
|
||||
}
|
||||
############################################################
|
||||
# PART 6.4
|
||||
#
|
||||
# Part 6.4 – XML konfigurieren
|
||||
############################################################
|
||||
|
||||
function Set-AnswerFileConfiguration {
|
||||
|
||||
Write-Log "Konfiguriere XML"
|
||||
|
||||
Set-VBRProperty "ACCEPT_EULA" "1"
|
||||
Set-VBRProperty "ACCEPT_LICENSING_POLICY" "1"
|
||||
Set-VBRProperty "ACCEPT_THIRDPARTY_LICENSES" "1"
|
||||
Set-VBRProperty "ACCEPT_REQUIRED_SOFTWARE" "1"
|
||||
|
||||
if($UseLicense)
|
||||
{
|
||||
Set-VBRProperty "VBR_LICENSE_FILE" $LicenseTarget
|
||||
}
|
||||
else
|
||||
{
|
||||
Set-VBRProperty "VBR_LICENSE_FILE" "0"
|
||||
}
|
||||
|
||||
Set-VBRProperty "VBR_SQLSERVER_INSTALL" "0"
|
||||
Set-VBRProperty "VBR_SQLSERVER_ENGINE" "0"
|
||||
|
||||
Set-VBRProperty "VBR_SQLSERVER_SERVER" $SQLConnection
|
||||
Set-VBRProperty "VBR_SQLSERVER_DATABASE" $DatabaseName
|
||||
Set-VBRProperty "VBR_SQLSERVER_AUTHENTICATION" "0"
|
||||
|
||||
Set-VBRProperty "VBR_ENTRAID_DATABASE_INSTALL" "0"
|
||||
|
||||
Set-VBRProperty "INSTALLDIR" $InstallPath
|
||||
Set-VBRProperty "VM_CATALOGPATH" $CatalogPath
|
||||
Set-VBRProperty "VBR_IRCACHE" $IRCachePath
|
||||
|
||||
Set-VBRProperty "VBRC_SERVICE_PORT" $GuestCatalogPort
|
||||
Set-VBRProperty "VBR_SERVICE_PORT" $VeeamServicePort
|
||||
Set-VBRProperty "VBR_SECURE_CONNECTIONS_PORT" $SecureConnectionPort
|
||||
Set-VBRProperty "VBR_RESTSERVICE_PORT" $RestServicePort
|
||||
|
||||
Set-VBRProperty "REBOOT_IF_REQUIRED" "$RebootRequired"
|
||||
|
||||
foreach($Plugin in $Plugins.Keys)
|
||||
{
|
||||
Set-VBRProperty `
|
||||
$Plugin `
|
||||
"$($Plugins[$Plugin])"
|
||||
}
|
||||
|
||||
}
|
||||
############################################################
|
||||
# PART 6.5
|
||||
#
|
||||
# Part 6.5 – XML validieren
|
||||
############################################################
|
||||
|
||||
function Test-AnswerFile {
|
||||
|
||||
Write-Log "Prüfe XML"
|
||||
|
||||
if(!$AnswerXML.unattendedInstallationConfiguration)
|
||||
{
|
||||
Stop-Installation "Ungültige XML."
|
||||
}
|
||||
|
||||
if(!$AnswerXML.unattendedInstallationConfiguration.properties)
|
||||
{
|
||||
Stop-Installation "XML Properties fehlen."
|
||||
}
|
||||
|
||||
Write-Log "XML erfolgreich geprüft."
|
||||
|
||||
}
|
||||
############################################################
|
||||
# PART 6.6
|
||||
#
|
||||
# Part 6.6 – XML speichern
|
||||
############################################################
|
||||
|
||||
function Save-AnswerFile {
|
||||
|
||||
Write-Log "Speichere XML"
|
||||
|
||||
try
|
||||
{
|
||||
$Writer = New-Object System.Xml.XmlTextWriter(
|
||||
$AnswerFile,
|
||||
[System.Text.Encoding]::UTF8
|
||||
)
|
||||
|
||||
$Writer.Formatting = "Indented"
|
||||
|
||||
$AnswerXML.Save($Writer)
|
||||
|
||||
$Writer.Close()
|
||||
|
||||
Write-Log "Antwortdatei gespeichert"
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
Stop-Installation "Antwortdatei konnte nicht gespeichert werden.`n$($_.Exception.Message)"
|
||||
}
|
||||
|
||||
}
|
||||
############################################################
|
||||
# PART 6.7
|
||||
#
|
||||
# Part 6.7 – Gesamtablauf
|
||||
############################################################
|
||||
|
||||
function Initialize-AnswerFile {
|
||||
|
||||
Copy-AnswerFile
|
||||
|
||||
Open-AnswerFile
|
||||
|
||||
Set-AnswerFileConfiguration
|
||||
|
||||
Test-AnswerFile
|
||||
|
||||
Save-AnswerFile
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user