Tag Archives: Lab management

Removing dead library servers and hosts from SCVMM

A while back I was setting up TFS Lab management so that we can start automating a lot of our integration testing. In the process of testing the deployment of the servers and the auto configuration scripts I was creating a lot of temporary virtual servers on the domain and using up IP’s on the network before they could be released. Therefore I wasn’t too popular with the OP’s guys and they decided to put the lab server in it’s own domain.

Unfortunately this caused a few issues as it meant that the SCVMM backed could not contact the hosts and the library servers as they had moved domain. Removing the hosts was a simple matter of dropping to PowerShell (There is a handy button at the top of the SCVMM Admin console) and running the following command:

Remove-VMHost "[SERVER_FQDN]" -Force

However the PowerShell command for removing dead library servers is not so helpful as it doesn’t have a “Force” flag and it comes up with an error saying it can’t be contacted:

Error (406) - Access has been denied while contacting the server

Luckily as the SCVMM backend is controlled by Sql server it wasn’t too difficult to find where the definitions of the library server were stored. Just connect to the SCVMM database instance ([YOUR_SCVMM_SERVER]\MICROSOFT$VMM$) and the table you need to look at is the tbl_ADHC_Library table. Firstly do a select on the table to get the GUID/UNIQUEIDENTIFIER of the library server(s) you need to delete:

use VirtualManagerDB

from dbo.tbl_ADHC_Library

From this query take the LibraryID field and for each of the library servers you need removing, run the following command:

use VirtualManagerDB

exec prc_ADHC_Library_Delete '[LibraryID]'

Hey presto all the dead servers are now gone!

As always please make sure you have a backup and don’t blame me if you break your SCVMM server!!