############################################################ # PART 3 # # Installationsquelle # Lizenz # SQL Prüfung ############################################################ ############################################################ # INSTALLATIONSQUELLE ############################################################ function Select-InstallationSource { Write-Host "" Write-Host "Veeam Installationsquelle" Write-Host "=========================" Write-Host "1 = DVD / ISO ($DVDSource)" Write-Host "2 = Netzwerk ($NetworkSource)" Write-Host "" do { $Choice = Read-Host "Quelle auswählen" } until ($Choice -in @("1","2")) switch($Choice) { "1" { $Script:VeeamSource = $DVDSource } "2" { Connect-NetworkSource } } Write-Log "Installationsquelle: $VeeamSource" } ############################################################ function Connect-NetworkSource { Write-Log "Verbinde Netzwerkquelle" $Credential = Get-Credential if(Get-PSDrive VEEAMSRC -ErrorAction SilentlyContinue) { Remove-PSDrive VEEAMSRC -Force } New-PSDrive ` -Name VEEAMSRC ` -PSProvider FileSystem ` -Root $NetworkSource ` -Credential $Credential ` -ErrorAction Stop | Out-Null $Script:VeeamSource = "VEEAMSRC:\" } ############################################################ # INSTALLER ############################################################ function Find-VeeamInstaller { $Script:VeeamInstaller = Join-Path ` $VeeamSource ` "Setup\Silent\Veeam.Silent.Install.exe" if(!(Test-Path $VeeamInstaller)) { Stop-Installation "Veeam Installer wurde nicht gefunden." } Write-Log "Installer gefunden" } ############################################################ # ANSWER FILE ############################################################ function Find-AnswerFile { $Script:AnswerFileSource = Join-Path ` $VeeamSource ` "Setup\Silent\AnswerFiles\VBR\VbrAnswerFile_install.xml" if(!(Test-Path $AnswerFileSource)) { Stop-Installation "Antwortdatei wurde nicht gefunden." } Write-Log "Antwortdatei gefunden" } ############################################################ # LIZENZ ############################################################ function Find-LicenseFile { $Script:LicenseSource = Join-Path ` $VeeamSource ` "License\veeam.lic" $Script:LicenseTarget = Join-Path ` $WorkDir ` "veeam.lic" if(Test-Path $LicenseSource) { Copy-Item ` $LicenseSource ` $LicenseTarget ` -Force $Script:UseLicense = $true Write-Log "Lizenz gefunden" } else { $Script:UseLicense = $false Write-Log "Community Edition" } } ############################################################ # SQL ############################################################ function Initialize-SQL { $Script:SQLServer = $env:COMPUTERNAME $Script:SQLConnection = "$SQLServer\$SQLInstance" } ############################################################ function Test-SQLService { Write-Log "Prüfe SQL Dienst" $ServiceName = "MSSQL`$$SQLInstance" $Service = Get-Service ` -Name $ServiceName ` -ErrorAction SilentlyContinue if(!$Service) { Stop-Installation ` "SQL Instanz '$SQLInstance' wurde nicht gefunden." } if($Service.Status -ne "Running") { Stop-Installation ` "SQL Dienst läuft nicht." } Write-Log "SQL Dienst OK" } ############################################################ function Test-SQLConnectivity { Write-Log "Prüfe SQL Verbindung" try{ Add-Type -AssemblyName System.Data $Connection = New-Object ` System.Data.SqlClient.SqlConnection $Connection.ConnectionString = "Server=$SQLConnection;" + "Integrated Security=True;" + "Connection Timeout=5;" $Connection.Open() $Connection.Close() Write-Log "SQL Verbindung erfolgreich" } catch{ Stop-Installation ` "Keine Verbindung zu $SQLConnection möglich.`n$($_.Exception.Message)" } } ############################################################ # VEEAM BEREITS INSTALLIERT? ############################################################ function Test-VeeamInstalled { Write-Log "Prüfe vorhandene Installation" $Service = Get-Service ` -Name "VeeamBackupSvc" ` -ErrorAction SilentlyContinue if($Service) { Stop-Installation ` "Veeam Backup & Replication ist bereits installiert." } Write-Log "Keine vorhandene Installation" } ############################################################ # GESAMTPRÜFUNG ############################################################ function Initialize-InstallationSource { Select-InstallationSource Find-VeeamInstaller Find-AnswerFile Find-LicenseFile Initialize-SQL Test-SQLService Test-SQLConnectivity Test-VeeamInstalled }