2012-03-20

Open-SDK–Opening the vSphere Management SDK

When writing scripts (I am a fan of PowerCLI of course) there is many a time when I need to get something out of the vSphere SDK so I can dig in and get the details that I am looking for.

Of course you could always go out to the internet and look for what you would like.

But sometimes I do my coding when in transit (don’t worry I am not driving) - and have no internet connection - so I like to have the SDK with me on my laptop.

I downloaded the SDK Package from here.

I extracted the package to C:\Program Files\VMware\SDK

The following function opens the SDK locally - and if not will try and open the correct web page.

#==============================================================
# NAME: Open-SDK
# AUTHOR: Maish Saidel-Keesing
# DATE  : 20/03/2012
# COMMENT: Will open the vSphere SDK from the local disk or from the Internet
# SOURCE: http://bit.ly/GEb6mk
#==============================================================

function Open-SDK () {
    param ()
    PROCESS {
            $test = Test-Path -Path "C:\Program Files\VMware\SDK\vSphereManagementSDKReadme.html" 
            if ($test -eq "$true")  {
                Invoke-Item "C:\Program Files\VMware\SDK\vSphereManagementSDKReadme.html"
            } elseif {
            Write-Host -ForegroundColor Yellow"You do not have the vSphere SDK installed on your System! Trying to open a web page"
            start http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/right-pane.html
            }
else {
Write-Host -ForegroundColor Red"You do not have the vSphere SDK installed on your System and no access to the internet!"; break
}
    }
}

##Entry point to script
Open-SDK

Just one of the few nice tools to make your life easier.