This past week I needed to remove multiple drivers from SCCM and replace them with updated versions. The only way to do this via the console is one by one. This probably isn’t a big deal if you only have a couple of different platforms however once you start getting into double digits it gets time consuming. You can disable multiple drivers at once but not delete – hopefully this was just a miss by Microsoft and will be resolved in upcoming versions of SCCM. Luckily I found a post by Rod Trent (http://myitforum.com/cs2/blogs/rtrent/archive/2008/11/12/script-to-delete-drivers.aspx) in which he has provided a script that will delete all disabled drivers. This is very handy if you want to delete some drivers but not all. (Most likely scenario for SCCM administrators) Anyway I ended up running this script from my primary site server and within minutes all of my disabled drivers had been removed.
' Connect to the SMS namespace
siteNamespace = GetSiteNamespace()
SET objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}!"_
&siteNamespace)
SET drivers = objWMIService.ExecQuery("SELECT * From SMS_Driver")
numDriversDeleted = 0
' Process the results
FOR EACH driver in drivers
IF driver.IsEnabled = 0 THEN
driver.Delete_
numDriversDeleted = numDriversDeleted +1
END IF
NEXT
WScript.Echo "Successfully deleted "&numDriversDeleted&" drivers."
'
' Utility function to search for the site namespace
'
FUNCTION GetSiteNamespace()
' Find SMS Provider
SET objSMSNamespace = GetObject("winmgmts:{impersonationLevel="&_
"impersonate}!\\.\root\sms")
SET results = objSMSNamespace.ExecQuery("SELECT * From "&_
"SMS_ProviderLocation WHERE ProviderForLocalSite = true")
' Process the results
FOR EACH r in results
namespacePath = r.NamespacePath
NEXT
' Fail if we did not find the site
IF namespacePath = "" THEN
WScript.Echo "Failed to locate SMS provider."
WScript.Quit 1
END IF
' Return
GetSiteNamespace = namespacePath
END FUNCTION
Update: This issue has been resolved in Confg Mgr SP2