Opened up Hyper-V today and all of my VMs where missing… umm what?

So I tried to connect to a server (button far right)

POPUP ERROR

Error Text
“Hyper-V encountered an error trying to access an object on computer ‘localhost’ because the object was not found. The object might have been deleted. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator.”
Troubleshooting
Checked Services they are running
Checked optional components they are running
Tried to run PowerShell Get-VM… ERRORS!
Long story short it turns out that a recent uninstall had deleted a MOF
Fix
Run the following command from an Elevated (Administrator) command prompt or PowerShell. Winkey+X >> Windows PowerShell (Admin)
MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof
Summary
Sometimes an uninstaller for an application has unintended consequences! Good news it was an easy fix of just recompiling the MOF (Microsoft Object Format). WMI is awesome but so touchy.
Like this:
Like Loading...
Published by shauncassells
Shaun Cassells, Senior Solutions Engineer, 1E
Shaun is a Microsoft MVP Windows Insider MVP and executive at Central Texas Systems Management User Group (CTSMUG). Shaun is a frequent speaker at conferences like MMS, Gartner, TechEd Europe, TechEd North America, IT Dev Connections, System Center Rallies, and Systems Management User Groups (SMUGs). Shaun is an award winning blogger syndicated from www.shauncassells.com. Shaun specializes in analysis, optimization, and design of Tactical Solutions to Strategic Business Goals. Prior to joining 1E in 2010, he worked for a Global 100 company as the Configuration Manager Service Owner and Architect. Recently as a Principle Consultant at 1E, he accomplished design, review, and improvements to a variety of Configuration Manager environments from the very small to sites with a half million seats. He provided leadership that created a patented automated application rationalization and usage based OSD mapping solution in use by multiple fortune 500 companies. These days you can find Shaun traveling to help discover, review, and improve business productivity across the world.
View all posts by shauncassells
So, tried your solution… (running as administrator) got this:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\WINDOWS\system32> MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof
Microsoft (R) MOF Compiler Version 10.0.17134.1
Copyright (c) Microsoft Corp. 1997-2006. All rights reserved.
Parsing MOF file: C:\WINDOWS\System32\WindowsVirtualization.V2.mof
MOF file has been successfully parsed
Storing data in the repository…
An error occurred while opening the namespace for object 1:
0X80041002 Class, instance, or property ” was not found.
Compiler returned error 0x80041002
PS C:\WINDOWS\system32>
LikeLike
thank you so much, a single command has resolved this.
LikeLike
Worked great. What a life saver.
LikeLike
Thanx, it fixed my problem!
LikeLike
truly you are BATMAN. thank you sir
LikeLike
Thank you!
LikeLike
It does not work for me, tried all the ways found in Internet, run above command, resinstall HyperV component, change hostname
LikeLike
What was the exact error you were getting? Fun Fact: if you have the error popup dialog selected you can use the keyboard shortcut Ctrl+C to copy all the text.
LikeLike
Hey Shauncassells !
Below error occurs, tried all solution including upper one. But still Hyper-V not working.
Can you please help me out.
Hyper-V Manager
[Main Instruction]
An error occurred while attempting to connect to server “DESKTOP-J9DEPHB”. Check that the Virtual Machine Management service is running and that you are authorized to connect to the server.
[Content]
Hyper-V encountered an error trying to access an object on computer ‘DESKTOP-J9DEPHB’ because the object was not found. The object might have been deleted. Verify that the Virtual Machine Management service on the computer is running.
LikeLike
Below error occurs, tried all solution including upper one. But still Hyper-V not working.
Is there anyone who can help me out.
Hyper-V Manager
[Main Instruction]
An error occurred while attempting to connect to server “DESKTOP-J9DEPHB”. Check that the Virtual Machine Management service is running and that you are authorized to connect to the server.
[Content]
Hyper-V encountered an error trying to access an object on computer ‘DESKTOP-J9DEPHB’ because the object was not found. The object might have been deleted. Verify that the Virtual Machine Management service on the computer is running.
LikeLike
Did you run the Mofcomp? What output did you get?
Also, I am guessing you checked to ensure the Hyper-V service is started.
LikeLike
Thanks a lot! You saved me a lot of time searching!
LikeLike
Great Job, i was having the same problem!!
LikeLike
I got this from Dan Hoeger on this thread.. https://social.technet.microsoft.com/Forums/en-US/0a29c671-b640-4c2d-954f-622b25f65ad9/hyperv-encountered-an-error-trying-to-access-an-object-on-computer-object-was-not-found?forum=win10itprovirt
– Open “Window Security”
– Open “App & Browser control”
– Click “Exploit protection settings” at the bottom
– Switch to “Program settings” tab
– Locate “C:\WINDOWS\System32\vmcompute.exe” in the list and expand it
– Click “Edit”
– Scroll down to “Code flow guard (CFG)” and uncheck “Override system settings”
– Start vmcompute from powershell “net start vmcompute” or from services app
Hyper-V manager can now connect to my local server!!! Whoop
LikeLike
this is the answer for windows 10 1909 and above
LikeLike
when running the command it ends normally. no error message in powershell but same hype v error r
LikeLike
Worked for me on Windows 10 Version 1703.
LikeLike
Worked! Thank you!
LikeLike
great work
LikeLike
curiously, I could manage my upgraded Server 19 from another host, but not itself – not until I ran your lifesaver. Fixed it right up – thank you!!!
LikeLike
Thank you so much
LikeLike
hero
LikeLike
meow
LikeLike
LikeLike
Thank you so much, it worked
LikeLike
Spot up with this write-up, I truly feel this fabulous website wants additional consideration. I’ll likely to end up again to read much more, thank you for that info.
LikeLike
Thank you. Life saver…
LikeLike
Can I buy you some cookies? This was exactly the fix I needed.
LikeLike
Thanks so much – sorted me out first time.
LikeLike
Got this issue upgrading from Server 2012r2 to 2019 and your solution fixed it, thanks!
LikeLike
Thanks couple of hours of trying to fix it then found this link and fixed in 30 seconds!
LikeLike
I had the same problem, tried this what Shaun wrote but it didn’t solve it. Then I managed to solve it by doing the following:
1. Open “Window Security”;
2. Open “App & Browser control”;
3. Click “Exploit protection settings” at the bottom;
4. Switch to “Program settings” tab;
5. Locate “C:\WINDOWS\System32\vmcompute.exe” in the list and expand it;
6. Click “Edit”;
7. Scroll down to “Code flow guard (CFG)” and uncheck “Override system settings”;
8. Start vmcompute from powershell by typing “net start vmcompute”.
LikeLike
MY HERO!!!!
Thank you so much!
LikeLike
I am running my dev environment in a Windows 10 LTSC VM on corporate given hardware in order to isolate myself as much as possible from bureaucracy while still following company policy, though perhaps blurring lines slightly, and corporate still managed to muck up my dev environment. Your web page keeps on giving, even day after Christmas. Thank you so much!!!
LikeLike
Thank you Shaun – bashing my head with this one on a [virtually] fresh host install 🙂
LikeLike
Boot drive was failing so cloned it onto and SSD. After booting with new drive docker startup was failing with this error. Went into Hyper-V Manager and tried to connect to local server and got the same error. Ran the command to recompile file and it was this fix. Everything is working now, docker starts up no errors. Thanks!
LikeLike
Thanks soo much – thought I had destroyed all my Labs and had to start again 😦 – you are a lifesaver
LikeLike
Thanks a lot. I ran into this problem and Your solution worked.
LikeLike
Thanks a lot , It worked
LikeLike
Wow what an easy solution, I have spent the best part of 4 hours trying to fix this as two or my hosts were having this issue, tried a number of other recommended ways to fix it with no success. You saved the day.
Thanks
LikeLike
Thanks a lot. It worked for me.
LikeLike
THANK YOU! Your FIX solved my problem! I spent about a day on this already!
LikeLike
Thanks. This saved my Butt.
LikeLike
Thank you! Worked like a charm.
LikeLike
Awesome, Thanks a Lottt… 🙂
LikeLike
Thank you so much! Running MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof from elevated command prompt immediately fixed this. Thank you thank you thank you!!!
LikeLike
Server 2019, could NOT connect but managed from a 2012-R2 server even setting up a VM.
Worked a treat after command.
LikeLike