Datasheet

6 CHAPTER 1
AUTOMATING VCENTER SERVER DEPLOYMENT AND CONFIGURATION
items clearly de ned within the script, using a script like this ensures each installa-
tion is con gured correctly and no mistakes are made.
LISTING 1.1
Sample script for an automated installation of vCenter Server
Function New-RegKey ($RegLocation, $RegKey, $RegValue) {
If (Test-Path $RegLocation) {
} Else {
Write “Creating Registry Key $RegLocation”
Mkdir $RegLocation | Out-Null
}
If (Get-ItemProperty $RegLocation $RegKey `
-ErrorAction SilentlyContinue) {
Write “Registry Key ‘$RegKey’ already Exists.”
} Else {
Write “Creating $RegKey with a value of $RegValue”
New-ItemProperty -Path $RegLocation -Name $RegKey `
-Value $RegValue `
| Out-Null
}
}
#Install VC unattended
$VCMedia = “C:\Temp\InstallMedia”
$LiKey = “XXX-XXX-XXX-XXX”
$Username = “My Name”
$CompanyName = “My Company”
$ODBCName = “vCenter Database”
$DBSrv = “SQL2005DB”
$DBUser = “VMware”
$DBPass = “VCDataba53”
# For SQL 2008 connections ensure the database client is installed
If (-Not (Test-Path ‘C:\WINDOWS\system32\sqlncli10.dll’)) {
Write “SQL 2008 Native Client not found.
Install it & then re-run this script”
Exit
}
#Create DSN connection
890790c01.indd 6890790c01.indd 6 3/3/11 10:22:15 AM3/3/11 10:22:15 AM