More PS Fun : Fix vCenter Startup w/ PowerShell

More to come on this, but I am working more hands-on lately in my role as a vSpecialist. As part of this I am going to make an effort to post every *shortcut* I come up with along the way. And I love shortcuts…

So here is another PowerShell trick. As many of you have experienced. If you have a local SQL server installation (express or not) of vCenter you will sometimes have vCenter not start correctly on boot. This is do to a race condition between the SQL Server services and vCenter. If SQL doesn’t beat vCenter then vCenter will not start. The correct way to fix this is to setup the Dependencies with the vCenter VPXD service to wait till SQL has done its business first. There are actually several good articles out there on how to do this manually.

I don’t like to anything manually, so here is a PowerShell script to auto-detect and configure vCenter startup for local SQL installs. It is setup to work with SQL server or SQL server express. I think I got all bases covered but you can easily customize as you like (or use on other services).

*Disclaimer: Always backup or test before doing this on something important. A registry export of HKLM:SYSTEMCurrentControlSetservicesvpxd would be smart*

**update** I added some fixes for Windows 2003 systems (3/10/2011)


# This script fixes dependecy issues with vCenter installed with a local SQL server Instance.
# Run this from PowerShell on the vCenter Host or through Remote PowerShell if configured.
# This only needs to be run once
# Nick Weaver / / 3.10.2011
$deplist = @()
$deplist += "ProtectedStorage"
$deplist += "lanmanworkstation"

$a=Get-Service -Name "ADAM_VMwareVCMSDS" -ErrorAction silentlycontinue
if ($a -ne $null) {
	$deplist += $a.Name
$b=Get-Service -Name "MSSQLSERVER" -ErrorAction silentlycontinue
if ($b -ne $null) {
	$deplist += $b.Name
$c=Get-Service -Name "*SQLEXP_VIM" -ErrorAction silentlycontinue
if ($c -ne $null) {
	$deplist += $c.Name

Set-ItemProperty -path "HKLM:SYSTEMCurrentControlSetservicesvpxd" -name DependOnService -Value $deplist
Write-Host "**Services added for dependecy**"
(Get-ItemProperty -path "HKLM:SYSTEMCurrentControlSetservicesvpxd").DependOnService

As always, post better versions in the comments to show me up Smile


EMC Scripts Tools

3 Comments Leave a comment

%d bloggers like this: