Site icon Virtually Sober

vSphereCMDB

Have you ever had a situation where you needed to know the settings a VM had 1 month ago? Wanted to see historical VM disk usage? Track the growth of VMs in a cluster? Somebody renamed a VM and you can’t find it anymore? Today, with just a vCenter, once the change is made the data has gone and you can’t see what it was before.

All these challenges can be solved by creating a vSphere Change Management Database (vCMDB). Using PowerShell and Microsoft SQL Server it’s possible to log all the vSphere information into a SQL database on an hourly, daily, or weekly basis. You can then easily report on the data from any point in time. Pretty useful huh?

To get started, install a SQL Server if you don’t already have one (any version of express works fine). You can get it here. Next, download the below zip file:

vSphereCMDBv1.1.zip

Included are 5 PowerShell scripts to run in the following order:

Each script is configured to connect to a local SQLEXPRESS instance, but you can easily change the variable to connect to a remote SQL server too. If the SqlServer or PowerCLI modules aren’t installed on the host they are automatically installed from the PSGallery.

Once you’ve started logging data into your vCMDB you’ll be amazed at the information you can now ascertain that was previously unknown. Here are some of my top examples:

This is my gift for you to implement and take as your own within whether you work. All I ask is that if you use it professionally, then please add a comment saying what you used it for and I hope you found it useful! Happy scripting,

Joshua

Exit mobile version