My colleague created a virtual machine for me in our datacentre a few weeks ago. (Thanks Michael!) Earlier this week I needed to create a second virtual machine to cluster with it, and I felt that the best way to maximize my resources completely would be to create another virtual machine identical to the first. Okay, all I had to do was pop open the Settings window for the virtual machine and copy it.
We have 25 physical host servers in the lab environment in question, and no Virtual Machine Manager. Crap.
I could, if I had to, connect to each host one by one looking for the virtual machine in question, but that would be a waste of time… not to mention that as a one-off solution it could work, but it is a bad habit to get into. I needed a better solution.
If you ever find yourself in the position, here’s a tip: As long as you have the Integration Services installed, there is a registry key in the virtual machine that gives me my answer. So open Regedit and navigate to:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters
See? There it is, right there in black and white. In fact, it’s there three times – under HostName, PhysicalHostName, and PhysicalHostNameFullyQualified. I no longer need a map, I no longer need to go looking by hand.
But Mitch, isn’t there a way to do this in PowerShell?
I’m glad you asked. Sure, here it is:
(Get-ItemProperty –path “HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters”).PhysicalHostName
Of course, if you are a stickler about it, you can change the last bit to PhysicalHostNameFullyQualified, but that’s up to you.
Now that you know where you are… keep going!
Leave a Reply