Force Remove Virtual Machine Manager library

There is no

Remove-SCLibraryServer -Force

command but you can still delete a non-existent VMM Library Server.
First open up the SQL Management studio and execute the following query to find out your VMM Library server ID:

use VirtualManagerDB
go

select 
    LibraryID,
    ComputerName
from dbo.tbl_ADHC_Library

You’ll see an ID similar to the one below.

Force_remove_VMMLIB

Next, remove the Library using the following query using the default stored-procedure:

use VirtualManagerDB
go

exec prc_ADHC_Library_Delete '[LibraryID]'

If you get a “Command(s) completed succesfully.” you’re done!

You could receive error messages like the ones below.

Msg 547, Level 16, State 0, Procedure prc_ADHC_Library_Delete, Line 16
The DELETE statement conflicted with the REFERENCE constraint “fk_ADHC_HostVolume_ADHC_Library”. The conflict occurred in database “VirtualManagerDB”, table “dbo.tbl_ADHC_HostVolume”, column ‘LibraryServerID’.
The statement has been terminated.

Msg 547, Level 16, State 0, Procedure prc_ADHC_Library_Delete, Line 16
The DELETE statement conflicted with the REFERENCE constraint “fk_ADHC_HostDisk_ADHC_Library”. The conflict occurred in database “VirtualManagerDB”, table “dbo.tbl_ADHC_HostDisk”, column ‘LibraryServerID’.
The statement has been terminated.

This is caused because there are dependent records in related database tables tbl_ADHC_HostVolume and tbl_ADHC_HostDisk.

Use the following query’s to delete these records

use VirtualManagerDB
go

delete from tbl_ADHC_HostDisk
where LibraryServerID like '[LibraryID]'

delete from tbl_ADHC_HostVolume
where LibraryServerID like '[LibraryID]'

And run the default stored-procedure again.

use VirtualManagerDB
go

exec prc_ADHC_Library_Delete '[LibraryID]'

One thought to “Force Remove Virtual Machine Manager library”

Leave a Reply

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