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}!”_

                               &siteNamespace)

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

numDriversDeleted = 0

‘ Process the results

FOR EACH driver in drivers

    driver.Delete_

    numDriversDeleted = numDriversDeleted + 1

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

Advertisements

One Response

  1. […] https://poseidom.wordpress.com/2008/08/06/script-to-delete-drivers-from-sccm-in-mass/ 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:

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: