In a previous post, I said that there was no real way of extracting information from the VC database.

This isn’t entirely true, as until I started using PowerShell, I was using SQL to query the VC database directly.

List XP Machines and their RAM allocation

SELECT VPX_VM.GUEST_OS, VPX_VM.MEM_SIZE_MB
FROM VC_DB.dbo.VPX_VM VPX_VM
WHERE (VPX_VM.GUEST_OS='winXPProGuest')

List Information about Templates

SELECT VPX_VM.LOCAL_FILE_NAME, VPX_VM.GUEST_OS, VPX_VM.IS_TEMPLATE, VPX_VM.MEM_SIZE_MB, VPX_VM.HOST_ID, VPX_VM.ID
FROM VC_DB.dbo.VPX_VM VPX_VM
WHERE (VPX_VM.IS_TEMPLATE=1)
ORDER BY VPX_VM.LOCAL_FILE_NAME

Host names and memory

SELECT VPX_HOST.ID, VPX_HOST.DNS_NAME, CAST (VPX_HOST.MEM_SIZE AS BIGINT)
FROM VC_DB.dbo.VPX_HOST VPX_HOST
ORDER BY VPX_HOST.DNS_NAME

Guest Information

SELECT VPX_VM.LOCAL_FILE_NAME, VPX_VM.DNS_NAME, VPX_VM.GUEST_OS, VPX_VM.IS_TEMPLATE, VPX_VM.IP_ADDRESS, VPX_VM.MEM_SIZE_MB, VPX_VM.GUEST_STATE, VPX_VM.POWER_STATE, VPX_VM.HOST_ID, VPX_VM.ID, VPX_VM.BOOT_TIME
FROM VC_DB.dbo.VPX_VM VPX_VM
WHERE (VPX_VM.IS_TEMPLATE<>;1)
ORDER BY VPX_VM.DNS_NAME, VPX_VM.LOCAL_FILE_NAME

These were based on ideas from Wayne’s World of IT. While it’s a lot less friendly to work with, the advantage is that it’s a lot quicker than the VI Toolkit’s Get- commands, and I still use them from time-to-time.

Although you could use this approach to modify entries in the database, I would only ever feel comfortable using this to extract information.

Comments

Leave a Reply