Script VBS 3 in 1, a function to delete a package SCCM, a collections SCCM or a advertisements

Function FdeleteInstanceSCCMClass(strCLass , StrNameInstance, Strrocessing)

Set loc = CreateObject( "WbemScripting.SWbemLocator" )
Set WbemServices = loc.ConnectServer( StrSCCMServerName,"root\SMS\site_" & SiteCode)
strQry =  "select * from " & strCLass & " where name='" & StrNameInstance & Strrocessing & "'"
Set instances = WbemServices.ExecQuery(strQry)

    If instances.Count = 0 Then
    Else
        For Each instance In instances
          instance.Delete_
       Next
    End If

Set instances = Nothing
Set WbemServices = Nothing
Set strQry = Nothing
Set loc = Nothing
End Function

FdeleteInstanceSCCMClass "SMS_Collection",StrPackageName,StrUninstallFlag
FdeleteInstanceSCCMClass "SMS_Package",StrPackageName,""
FdeleteInstanceSCCMClass "SMS_Advertisement",StrPackageName,StrInstallFlag

 

 

Monssef MESTOUR

Published 01-17-2012 12:16 by MESTOUR Monssef
Filed under: , , ,

Comments

# re: Script VBS 3 in 1, a function to delete a package SCCM, a collections SCCM or a advertisements

mardi 17 janvier 2012 17:34 by mbertuit

Interesting Monssef, thanks :-)