There are cases where computer might needs to be deleted from SCCM Database when the OS up gradation happens(new name applied to host machines) and old name should be removed else it will automatically be removed as per the site maintenance settings.
Here is VB script that remove computer from SCCM Database based asking for machine name.
Note :I would love to test this on Lab before taking this to production.
You would be prompted for SCCM Site server name(where SQL server installed) and site code for the Site server.
ON ERROR RESUME NEXT
strServer=InputBox("Enter Site Server Nmae",,"win-cm2k7")
strSiteCode=InputBox("Enter Site Code",,"P01")
strComputer = InputBox("Enter Machine Name To Delete",,"System name")
Set locator = CreateObject( "WbemScripting.SWbemLocator" )
Set WbemServices1 = locator.ConnectServer( strServer,"root\SMS\site_" & strSiteCode
ResID = getResID(strComputer, WbemServices1)
If ResID = Empty Then
MsgBox "Unable To Determine The ResourceId For " & strComputer & " Exiting Application"
MsgBox "The ResourceId For " & strComputer & " On " & strServer & " Is " & ResID
Set sResource = WbemServices1.Get("SMS_R_System='" & ResID & "'")
If Err = 0 Then
MsgBox strComputer & " Has Been Removed From " & strSiteCode
MsgBox "Unable To Locate " & strComputer & " On " & strServer
Set sResource = Nothing
Function GetResID(strComputer, oWbem)
strQry = "Select ResourceID from SMS_R_System where Name=" & "'" & strComputer & "'"
Set objEnumerator = oWbem.ExecQuery(strQry)
If Err <> 0 Then
GetResID = 0
For Each objInstance in objEnumerator
For Each oProp in objInstance.Properties_
GetResID = oProp.Value
Set objEnumerator = Nothing