Script to delete drivers from SCCM in mass

I will make no claim to ownership nor to having actually tried this script. However knowing how irritating it is to actually delete lots of drivers from CM I had to post this. It is taken from the TechNet forums apparently posted by someone from MS.


‘ Connect to the SMS namespace

siteNamespace = GetSiteNamespace()

SET objWMIService = GetObject( “winmgmts:{impersonationLevel=impersonate}!”_


SET drivers = objWMIService.ExecQuery(“SELECT * From SMS_Driver”)

numDriversDeleted = 0

‘ Process the results

FOR EACH driver in drivers


    numDriversDeleted = numDriversDeleted + 1


WScript.Echo “Successfully deleted “&numDriversDeleted&” drivers.”

‘ Utility function to search for the site namespace

FUNCTION GetSiteNamespace()

‘ Find SMS Provider

SET objSMSNamespace = GetObject(“winmgmts:{impersonationLevel=”&_


SET results = objSMSNamespace.ExecQuery(“SELECT * From “&_

“SMS_ProviderLocation WHERE ProviderForLocalSite = true”)

‘ Process the results

FOR EACH r in results   

        namespacePath = r.NamespacePath


‘ Fail if we did not find the site

IF namespacePath = “” THEN

        WScript.Echo “Failed to locate SMS provider.”

        WScript.Quit 1


‘ Return

    GetSiteNamespace = namespacePath