SCVMM 2012 | Force Remove vCenter Server

If you are reading this you likely took the plunge into Microsoft Virtual Machine Manager 2012, you added in your VMWARE vCenter, migrated some VM’s and then tried to jettison the old vCenter  that is no longer around.

If you did you likely got this error message:

VMM cannot complete the VMware operation on the <server> server because of the error: “Unable to connect to the remote server

image

You may have went for extra credit and run this powershell command without luck as well:

Get-VirtualizationManager -ComputerName <server> | Remove-VirtualizationManager

See unlike Remote-VMHost that has the –force switch you don’t have a –force switch with Remove-VirtualizationManager.

What is an admin to do??

Well if you are extremely irresponsible and want to blindly follow a guy with a blog who happened to find a way that at least looks like it worked then good Sir or Madam you are in the right place!!!

SQL Studio with Admin Rights

First you will need to run SQL Studio Manager with rights to the DB. If you have this then move on to the next section.

If like me you didn’t end up having permission to the default instance then run this nifty sysInternals tool PSEXEC:

PSEXEC –i –s cmd (make sure to run with admin rights)

If that works and you now have a cmd prompt go ahead and type whoami just for fun. you will see you are NT Authority\Local System!

Now go ahead and run the SQL Studio Manager from this command prompt. Given each version of SQL has this in a different location the easiest way would be to look at the properties of the start menu shortcut to find the full path to the executable.

The Query

Ah now once in SQL Studio with rights to the DB simple run this query to force remove the vCenter from your VMM instance.

HEY!!! SERIOUSLY I HAVE NO IDEA IF THIS IS SAFE!! USE AT YOUR OWN RISK.

DECLARE @computername varchar(255)
SET @computername = ‘<servername>’
DELETE FROM [tbl_ADHC_AgentServerRelation] WHERE AgentServerID = (select top 1 AgentServerID from tbl_ADHC_AgentServer where Computername = @computername)
DELETE FROM [tbl_ADHC_AgentServer] WHERE AgentServerID = (select top 1 AgentServerID from tbl_ADHC_AgentServer where Computername = @computername)
DELETE FROM [tbl_ADHC_Host] WHERE [HostID] = (select top 1 HostID from tbl_ADHC_Host where ComputerName = @computername)

Now, if I you know a better way please leave a comment.

If this helped you, please leave a comment. Love knowing my time wasn’t wasted.

If you are Microsoft and you feel I am leading people off a cliff, PLEASE PLEASE leave me a comment.

In any event, hope it helps and enjoy!

-Eric

9 Replies to “SCVMM 2012 | Force Remove vCenter Server”

  1. One small change was required for the query to remove the server from the database:

    DECLARE @computername varchar(255)
    SET @computername = ”
    DELETE FROM [tbl_ADHC_VmwResourcePool] WHERE [HostID] = (select top 1 HostID from tbl_ADHC_Host where ComputerName = @computername)
    DELETE FROM [tbl_ADHC_AgentServerRelation] WHERE AgentServerID = (select top 1 AgentServerID from tbl_ADHC_AgentServer where Computername = @computername)
    DELETE FROM [tbl_ADHC_AgentServer] WHERE AgentServerID = (select top 1 AgentServerID from tbl_ADHC_AgentServer where Computername = @computername)
    DELETE FROM [tbl_ADHC_Host] WHERE [HostID] = (select top 1 HostID from tbl_ADHC_Host where ComputerName = @computername)

    Added line: DELETE FROM [tbl_ADHC_VmwResourcePool] WHERE [HostID] = (select top 1 HostID from tbl_ADHC_Host where ComputerName = @computername)

    The vCenter server was in the tbl_ADHC_VmwResourcePool as well in my VMM 2012 installation.

      1. I dont have R2 yet (planned for a few months from now). However if you let me know which column name it has a problem with I might be able to help. Also change all the “DELETE FROM” to “SELECT * FROM” that might give you more info on whats wrong.

  2. I have error like this :

    Error (2951)
    Virtual Machine Manager cannot complete the VirtualCenter action on server vcenter.kairos-it.com because of the following error: Cannot complete login due to an incorrect user name or password. (InvalidLogin).

    Recommended Action
    This error occurs when an operation is denied access because of insufficient privileges on a managed object. Resolve the issue and then try the operation again.

    What should I do to fix that?

    thanks.

  3. Hey Eric,

    Thanks for posting this solution. I was able to do it directly from SQL management studio and it worked flawlessly

Leave a Reply

Your email address will not be published. Required fields are marked *