We run SCVMM 2012 SP1 in a Lab Management setting with TFS 2013.4 for a client. Over the years, we have run into many (many) issues caused by the VirtualManagerDb (and the Lab tables in the Team Project Collection db) losing track of items or linkages between objects. This has all happened without us ever manually editing the databases.
In more recent times, however, we've had to manually edit the database in order to keep the client up and running. There have been more than a few times when entire Labs were lost in SCVMM, or when the Library copy of a Lab pointed to live VMs, causing all kinds of havoc on the production system. The only way to keep the client from having to re-create their Labs has sometimes been to re-create the linkages between cells and re-insert correct information into the tables.
Most recently, we had an issue where [tbl_WLC_VObject] was missing a VObject (entire row just went missing, somehow) that happened to be a Checkpoint. The [tbl_WLC_VMInstance] and [tbl_WLC_HWProfile] rows existed, but the VObject that links all of these and presents them to VMM had vanished in the night. This eventually resulted in us not being able to deploy anything, and many operations (all deployments included) resulted in the following error:
Error (801) VMM cannot find VMSnapshot object 86e33502-71b9-4c78-8e7b-f94cdda56604. Recommended Action Ensure the library object is valid, and then try the operation again.
We ended up having to insert a new row, filling in the proper GUIDs to get SCVMM to pick the checkpoint up again, and allow us to have a working Lab Management system.
My question is this: Are there any scripts or procedures that check for missing references, orphans, etc. to keep the VirtualManagerDb in good shape? I’m thinking something along the lines of this script (which looks for and deletes orphaned VDrive objects). We would like to be able to identify and eliminate these dormant issues before they put the system on its back.
So far, I’ve written this, which identifies VMInstance objects that do not have a corresponding VObject reference:
SELECT a.VMInstanceId, a.VMId, b.HWProfileId, b.Description, a.VsvLocation, a.VmcLocation FROM dbo.tbl_WLC_VMInstance a INNER JOIN dbo.tbl_WLC_HWProfile b ON a.VMInstanceId = b.HWProfileId AND [VMInstanceId] NOT IN (SELECT ObjectId FROM dbo.tbl_WLC_VObject WHERE ObjectId IS NOT NULL) ORDER BY Description
Anyone have anything else?