VMWare View installation script – Part 1

Bonjour,

Afin de faciliter le déploiement de plateformes VDI en m’appuyant sur les technologies Horizon View de VMWare, j’ai du industrialiser l’installation de tous les composants.
Pour commencer cette série d’articles, je commencerais par l’installation de View Composer.

Ce script a été testé avec l’environnement suivant:
– Windows 2008 R2 US
– SQL Server Native Client 10
– VMWare View Composer 3.0

Le script va installer SQL Server Native Client si il ne l’est pas déjà, créer/recréer le connecteur ODBC et installer/réinstaller View Composer 3.0

Rien de bien compliqué, mais ça pourrait vous servir


[powershell] # This script ghas only been tested on Windows Server 2008 R2
# It shouldn’t be used on x86 system, ODBC DSN Creation won’t work, the registry path won’t exist !
param (
[Parameter(Mandatory=$true)] [String]$SQLServer,
[String]$DSNName = “ViewComposer”,
[String]$DBName = “viewcomposer”,
[String]$Login = “sql_comp”,
[String]$Password = “SomePassword”,
[String]$SQLBinaries = “C:tempsqlncli.msi”,
[String]$Binaries = “C:tempVMware-viewcomposer-3.0.0-691993.exe”
)

Function Add-DSNODBC {
param (
[String]$SQLServer,
[String]$DSNName,
[String]$DBName,
[String]$Login
)
$HKLMPath1 = “HKLM:SOFTWAREODBCODBC.INI” + $DSNName
$HKLMPath2 = “HKLM:SOFTWAREODBCODBC.INIODBC Data Sources”
md $HKLMPath1 | Out-Null
set-itemproperty -path $HKLMPath1 -name Driver -value “C:Windowssystem32sqlncli10.dll”
set-itemproperty -path $HKLMPath1 -name Description -value $DSNName
set-itemproperty -path $HKLMPath1 -name Server -value $SQLServer
set-itemproperty -path $HKLMPath1 -name LastUser -value $Login
set-itemproperty -path $HKLMPath1 -name Trusted_Connection -value “No”
set-itemproperty -path $HKLMPath1 -name Database -value $DBName
md $HKLMPath2 | Out-Null
set-itemproperty -path $HKLMPath2 -name “$DSNName” -value “SQL Server Native Client 10.0”
}

# Install SQL Server Native Client if needed
if (!(Test-Path “C:Windowssystem32sqlncli10.dll”)) {
Try {
Start-Process -FilePath “msiexec.exe” -Argumentlist “/i $SQLBinaries /qn IACCEPTSQLNCLILICENSETERMS=YES” -Wait
}
Catch {
throw (New-Object System.Exception(“Installation of SQL Server Native client failed.”,$_.Exception))
}
}
else {
Write-Warning “SQL Server Native client already installed”
}

# Add DSN ODBC
# The DSN will be over writted by this one if a previsouly same named exists
Try {
Add-DSNODBC -Server $SQLServer -DSNName $DSNName -DBName $DBName -Login $Login
}
Catch {
throw (New-Object System.Exception(“ODBC DSN Creation failed.”,$_.Exception))
}

# Install View Composer
$ComposerExecutable = “C:Program Files (x86)VMwareVMware View ComposerSviWebService.exe”
if (Test-Path $ComposerExecutable) {
Write-Warning “Composer already installed on server”
Write-Warning “The script will remove the previous installation”
$app = Get-WmiObject -Class Win32_Product -Filter “Name = ‘Vmware View Composer'”
$app.Uninstall() | Out-Null
Write-Host “The previous installation of View Composer is successfully removed.”
}

Start-Process -FilePath $Binaries -ArgumentList ‘/S /v”/qn DB_DSN=’ + $DSNName + ‘ DB_USERNAME=’ + $login + ‘ DB_PASSWORD=’ + $password + ‘”‘ -Wait
Write-Host “View Composer freshly installed.”

[/powershell]

 

Bonne journée,

A bientôt pour la suite de cette série d’articles.