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


One Response

  1. […] Published Wednesday, August 06, 2008 10:28 PM by rodtrent Filed under: System Center, ConfigMgr 2007 […]

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: