' 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
You must copy this code on a .vbs file...
Aucun commentaire:
Enregistrer un commentaire