Automate vCenter 4.1 64-bit DSN Creation

Back in the days of vCenter 4.0 it required a 32-bit DSN to connect to your SQL database. Now that vCenter 4.1 and ESX 4.1 are out, it now requires the use of a 64-bit DSN. This makes sense as vCenter now requires a 64-bit server. The PowerShell script I wrote last year automated the configuration of a 32-bit DSN. So I needed to do a couple of minor tweaks to make it create a 64-bit DSN.

If you are using Windows Server 2008/R2, make sure you run the PowerShell script as Administrator or it will fail with lots of error messages. The script is compatible with both SQL 2008 and SQL 2008 R2.


## Creates a 64-bit System DSN for vCenter Server.
## Version 1.0, 21 August 2010

$DSNName = “vCenter Server”
$DBName = “vCenter Server”

If($args[0] -eq $NULL) { echo “Must specify FQDN of SQL server.”; Exit}

$HKLMPath1 = “HKLM:SOFTWAREODBCODBC.INI” + $DSNName
$HKLMPath2 = “HKLM:SOFTWAREODBCODBC.INIODBC Data Sources”

md $HKLMPath1 -ErrorAction silentlycontinue
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 $args[0]
set-itemproperty -path $HKLMPath1 -name LastUser -value “Administrator”
set-itemproperty -path $HKLMPath1 -name Trusted_Connection -value “Yes”
set-itemproperty -path $HKLMPath1 -name Database -value $DBName

## This is required to allow the ODBC connection to show up in the ODBC Administrator application.

md $HKLMPath2 -ErrorAction silentlycontinue
set-itemproperty -path $HKLMPath2 -name “$DSNName” -value “SQL Server Native Client 10.0”

Just save the file on your vCenter server, open an elevated PowerShell command window and execute the script with an argument of the FQDN of your SQL server. For example:

DSN-vCenter64.ps1 SQL01.contoso.net

Be sure to change the database name variable to match what you configured in SQL.

Print Friendly, PDF & Email

Related Posts

Subscribe
Notify of
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Anonymous
September 22, 2010 12:11 am

Great script, I would just add note that you also need to install driver “SQL Server Native Client 10.0”
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=228DE03F-3B5A-428A-923F-58A033D316E1&displaylang=en)

Regards,
Mladen