0

I have been working on Hyper-V Failover Cluster for the past two months, And have also used the Live Migration feature and every other aspect of failover cluster with respect to its features. Now the point of my post is that, Is there any kind of programmatic way ( Either powershell script or C++ API) to determine the failover or failback history of the virtual machine ( In what all nodes the virtual machine has been moved ). Upon my analysis, I have found that these migration related activities would be in the Event Viewer with the EventID and the necessary details.But my concern is to have the same either through powershell or C++ API. Any help is highly appreciated.

Regards,
Dinesh Ramalingam

1 Answers1

0

I'm not sure about anything event driven to track this. In the past I've used SQL Server to query the registry for the VM to get it's current host then store this in a local log table. Then schedule that to build up a history and track the VM movements over time.

If the VM's are running SQL Server do something like this:

DECLARE @PhysicalHostName VARCHAR(20)

EXEC master..xp_regread 
    @rootKey = 'HKEY_LOCAL_MACHINE',
    @key = 'SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters',
    @value_name = 'PhysicalHostName',
    @value = @PhysicalHostName OUTPUT

SELECT
    @PhysicalHostName

If using SQL Server isn't an option yes PowerShell could be used to hit the registry using the Get-ItemProperty cmdlet.

Like this:

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters" -Name PhysicalHostName

If you got down the PowerShell route this is worth a read: https://msdn.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/working-with-registry-entries

Hope this helps.

Paul Andrew
  • 3,233
  • 2
  • 17
  • 37
  • Thanks for your reply.We can schedule the process to find the current owner node at regular time intervals, but the problem is that, what if the virtual machines migrates to and fro before the next schedule. And also If I execute the process that you specified in one node, and what if that node goes down. I will be losing the track records – Dinesh Ramalingam Jul 13 '16 at 08:08
  • I was able to get event details in the event viewer for virtual machine when live migration is performed , But could not get the event details in the event Viewer for the quick migration. why is it? – Dinesh Ramalingam Jul 25 '16 at 06:32