TSQL Script to manually remove an orphaned host or cluster from VMM
THIS WILL DELETE DATA FROM THE VMM DATABASE
NO GUARANTEES OR WARRANTIES
YOU MUST KNOW HOW TO BACKUP AND RESTORE YOUR VMM DATABASE
This script contains my additions as of 2021-01-20 and VMM 2019 to the script originally published at these sites, with all the same disclaimers and caveats
https://www.miru.ch/how-to-manually-remove-a-host-from-scvmm-2012-sp1/
https://philipflint.com/2017/07/24/how-to-delete-a-host-that-is-in-pending-state-in-scvmm/
To run this script
- Stop the VMM Service
- Launch SQL Server Management Studio and select your VMM database.
- New Query with current connection
BACKUP DATABASE VirtualManagerDB TO DISK = 'C:\Support\VirtualManagerDB.bak';
- Execute the backup
- New Query with current connection
SELECT [HostID], [ComputerName] FROM [tbl_ADHC_Host] WHERE [ComputerName] = '{host name}'
-
Note the HostID
-
New Query with current connection
-
Paste the Script DirectRemove-SCVMHost script
-
Replace {YourHostID} with the HostID identified above.
-
Execute and review the output for errors.
-
Restart the VMM Service