Home > 3rd Party Tools > Web Remote Console v3.21 Delete Device From SCCM

Web Remote Console v3.21 Delete Device From SCCM


Here is another button for Ron Crumbaker’s Web Remote Console v3.21.  This deletes the device from the SCCM database.

‘———————————————————————————-
‘This button will remove the device from the SCCM database.
‘———————————————————————————-
Sub Btnl???_OnClick
    on error resume Next
    Dim CompName, strSMSServer, strSMSSiteCode, objResource, intResourceID, strQuery, colResourceIDs, colResourceID, objResourceID
    CompName = trim(document.frmMain.txtValue.value)
    strQuery = “SELECT sms_R_System.ResourceID from sms_R_System where sms_R_System.Netbios_Name0 = ‘” & CompName & “‘”
    strSMSServer = “SERVERNAME”
    strSMSSiteCode = “???
    Set objLoc =  CreateObject(“WbemScripting.SWbemLocator”)
    Set objSMS= objLoc.ConnectServer(strSMSServer, “rootsmssite_” & strSMSSiteCode)
    IF Err THEN
        Err.Clear
        msgbox “Access Denied…you are not connected to SCCM.  Please verify your credentials.”
    ELSE
        if len(trim(CompName)) = 0 Then
            msgbox “Please type a Machine Name.”,,”Delete from SCCM”
        Else            Set colResourceIDs = objSMS.ExecQuery (strQuery)
            for each colResourceID in colResourceIDs
                objResourceID = colResourceID.ResourceID
                ‘msgbox colResourceID.ResourceID
            next            ‘Remove ResourceID
            Set objResource = GetObject(“WinMgmts:\” & strSMSServer & “rootSMSsite_” & strSMSSiteCode & “:SMS_R_System.ResourceID=” & cstr(objResourceID))
            objResource.Delete_
            msgbox “Deleted ” & CompName & ” which had a resource id of: ” & objResourceID & “.”
        end if
    END IF
End SUb

Advertisements
Categories: 3rd Party Tools
  1. RG
    July 6, 2012 at 12:29 pm

    Ok I finally created another and added your script in there with our dedicated smsserver and code and defining button.

    Now at least no error. But when clicking button nothing happens. I”m very beganner for this, can you advise?

    Thanks!

    • July 6, 2012 at 7:05 pm

      Any errors in the lower corner of IE? I know it requires ActiveX to be enabled too.

  2. chaakah
    May 15, 2012 at 10:22 am

    Hi I do get error saying “invalid character” on following line:
    strQuery = “SELECT sms_R_System.ResourceID from sms_R_System where sms_R_System.Netbios_Name0 = ‘” & CompName & “‘”

    Can you help please?

  3. chaakah
    April 10, 2012 at 10:37 am

    should this sub be in special area in the original script?
    I’m having trouble with this. Its giving me error.

    • April 13, 2012 at 10:44 am

      It doesn’t have to be anywhere special but without your error it is hard to say. Sorry!

      • RG
        July 6, 2012 at 9:38 am

        I”m adding this code in with rest of the subs and creating a button for it, which points to this sub. it give following error: “Invalid character” Line: 458.
        That line is following: Dim CompName, strSMSServer, strSMSSiteCode, objResource, intResourceID, strQuery, colResourceIDs, colResourceID, objResourceID

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: