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 |
Filed under: Uncategorized | 1 Comment »