System Center Virtual Machine Manager (VMM) is Microsoft’s recommended tool for managing multi-server Hyper-V deployments. That said, VMM has its issues. The most common issue is when the information displayed in the console doesn’t match what exists in real life. You may find, for example, that the VMM management console contains orphaned VM objects that don’t exist anymore.
In this article, I’ll explain why this issue happens. I’ll also show you what you can do to fix the problem.
Why Does VMM Display Orphaned Objects?
When VMM displays orphaned objects, it’s usually because admins used multiple tools to manage Hyper-V virtual machines. Take a look at the figure below to see why it happens. Earlier, I deployed a virtual machine, named VM4. Here, I’m deleting this virtual machine using the Hyper-V Manager.
Once the deletion process is complete, the Hyper-V Manager shows that VM4 no longer exists.
Ideally, that would be the end. Now, take a look at the VMM management console in the next figure. It still includes VM4 on the list of virtual machines. Yet, the Status column indicates that the virtual machine is missing. Incidentally, some older Virtual Machine Manager versions may take a long time to acknowledge that a VM is missing. In this case, VMM doesn’t acknowledge my VM4 deletion.
That happens because VMM stores the virtual machine inventory in its SQL Server database. I didn’t use the VMM management console to delete the VM. Instead, I used the Hyper-V Manager. That’s why the virtual machine object still exists in the database, even though I’ve deleted the VM itself.
Removing the Orphaned Objects
In most cases, the issue has an easy fix. Simply sync the VMM management console’s display and the Hyper-V Manager’s display. Here’s how you can do that in 2 quick steps:
- Right-click on a Hyper-V host
- Choose the Refresh Virtual Machines option from the shortcut menu
Forcing Removal from the Database
The Refresh Virtual Machines option often fixes the problem. That said, I’ve occasionally seen situations where it didn’t. If that happens, I recommend using a PowerShell command to force remove the virtual machine from the Virtual Machine Manager database.
Before I show you how to use PowerShell to remove an object from the VMM database, you need to know a couple things. First, I’m assuming that you’ve already deleted the virtual machine itself. Remember, this technique only removes an object from a database. It doesn’t actually delete the virtual machine itself.
You should also know that PowerShell doesn’t natively include the module required for this operation. That’s why you’ll need to use the Virtual Machine Manager Command Shell, not a raw PowerShell session.
Now that you’re ready for the fix, go ahead and open the Virtual Machine Manager Command Shell. When you do, enter the following command:
Get-ScVirtualMachine <virtual machine name> | Remove-ScVirtualMachine -Force
In my case, I’ve successfully deleted a virtual machine named VM4, but the VM4 object still exists in the VMM database. As such, the command that I need to use is:
Get-ScVirtualMachine VM4 | Remove-ScVirtualMachine -Force
When you execute this command, PowerShell will display many attributes related to the virtual machine you’re trying to remove. That makes it a bit difficult to tell if the operation has succeeded.
Don’t worry, though. The easiest way to check the operation’s status is to execute this command:
Get-SCVirtualMachine | Select-Object Name
It may take a few minutes, but the Virtual Machine Manager’s management console should eventually refresh itself. It’ll show that the virtual machine has been removed. If it doesn’t, you can always manually initiate a console refresh.
Removing Broken Objects
As a best practice, it’s normally a good idea to avoid using Hyper-V Manager if your organization uses Virtual Machine Manager. Still, I’ve occasionally seen Hyper-V Manager succeed where VMM fails.
Somewhat recently, for example, I had trouble using the VMM management console to delete a damaged Hyper-V virtual machine. I was able to remove the virtual machine through the Hyper-V Manager. Then, I simply refreshed the VMM virtual machine list to make VMM aware that I’ve deleted the damaged VM.
In most situations, the techniques in this article will successfully remove an orphaned Hyper-V virtual machine from the VMM database. I’ve never encountered a situation in which these techniques didn’t work. Even so, you could still encounter a situation where PowerShell simply can’t remove the orphaned object from the VMM database.
If this happens, you have one more option available. Microsoft provides a script that you can run from within the SQL Server Management Studio. It removes orphaned objects from the VMM database.
Will VMs be reported as missing if a Hyper-V server shuts down without live migrating the VMs to another server?
No. In that situation, VMM will eventually display a Host Not Responding error. The system doesn’t have any connection information to go on during this situation. That means it can’t differentiate between various connection event issues.
What will VMM display if a NAS containing the Hyper-V virtual machine files were to fail, but the Hyper-V server itself remains online?
Sometimes, the Hyper-V server can remain online, even after the failure of a NAS containing machine files. In that case, Virtual Machine Manager’s message will depend on the actual infrastructure configuration. Typically, though, VMM displays the VMs as stopped, not missing.
Can refreshing the VMM console fix the orphaned objects problem?
Yes, most of the time you can refresh the VMs in the VMM console to fix the problem. If it doesn’t, you’ll have to force remove the VM from the database. This isn’t an uncommon challenge with many pieces of software. That’s because you can only use basic database queries and directory checks can be used.
Under what circumstances should I use PowerShell to force a VM removal?
You should use PowerShell if refreshing the console doesn’t work. You should also use it if you primarily manage VMM from PowerShell, not the GUI console. That’s because the GUI’s coding could’ve fallen over for many reasons. Powershell, however, allows you to implement the removal through direct commands. If you have to do this often, you may want to create a script.
Why does a refresh operation take so long to complete?
Refreshes are queued jobs, like any other task in the operating system. If other jobs exist in the queue ahead of the refresh job, then you’ll see a delay before your refresh job runs.
1. Learn how to manually remove a VM from the VMM database using the SQL Server Management Studio.
2. Cope with a Hyper-V host that is not responding.
3. Learn how to get started with Hyper-V.
4. Find everything that you need to know about Virtual Machine Manager.
5. Learn about the syntax of the Remove-SCVirtualMachine cmdlet.