An error while attempting to delete the virtual machine - Hyper V

So I was trying to delete a virtual machine off my Hyper-V manager and kept getting the below error and I was unable to get rid of  it, so after a while I figured out that you have to delete a XML file stored in the location where the VM is actually stored and once you do that you should be able to delete the VM.. or in my case once I deleted the XML file the VM was automatically deleted from the Hyper-V manager and I only had to delete the folder manually!

"The operation cannot be performed while the object is in its current state"

The XML file looks something like the one below... SCCM was the name of my virtual machine in this case.