none
SCCM 2012 - How to delete packages from WMI?

Answers

  • I figured it out in powershell: 

    gwmi -Namespace root\sccmdp -Query "select * from SMS_PackagesInContLib where PackageID = 'XXX00043'" | Remove-WmiObject

    Now I will say to be careful. I deleted the wrong package by mistake the first time. Oddly enough thought the package I deleted by mistake is still in the admin console. Lucky for me it was just a test package but I wonder what the outcome will be from deleting it by mistake. 

    Wednesday, April 10, 2013 7:15 PM

All replies

  • I am having to same issue, I can find the packages in WMI but how on earth would I use WMI to delete it?
    Wednesday, April 10, 2013 5:27 PM
  • Hello,

    Take a look at the following link:

    http://systemscenter.ru/sccm2012sdk.en/html/e843aaf1-f278-447d-82b1-642f4286b65d.htm

    Follow the three steps in the article and you should be good to go. I haven't tested this myself though, so I can't guarantee that this will work for you.

    Wednesday, April 10, 2013 6:01 PM
  • You can always try an action in the admin console and then look at the smsprov.log to see what WMI classes/instances/methods were used in performing that action. This can make it much easier to script something by mimicking the SMS Provider calls the admin console makes. It's usually (not always) a pretty safe assumption that if you can do something in the admin console, you can perform that functionality through the provider as well.

    Also, check out the PowerShell cmdlets with SP1 as they may provide functionality that you're looking for.


    Check out my Configuration Manager blog at http://blogs.msdn.com/b/ameltzer

    Wednesday, April 10, 2013 7:02 PM
  • I figured it out in powershell: 

    gwmi -Namespace root\sccmdp -Query "select * from SMS_PackagesInContLib where PackageID = 'XXX00043'" | Remove-WmiObject

    Now I will say to be careful. I deleted the wrong package by mistake the first time. Oddly enough thought the package I deleted by mistake is still in the admin console. Lucky for me it was just a test package but I wonder what the outcome will be from deleting it by mistake. 

    Wednesday, April 10, 2013 7:15 PM
  • I figured it out in powershell: 

    gwmi -Namespace root\sccmdp -Query "select * from SMS_PackagesInContLib where PackageID = 'XXX00043'" | Remove-WmiObject

    Now I will say to be careful. I deleted the wrong package by mistake the first time. Oddly enough thought the package I deleted by mistake is still in the admin console. Lucky for me it was just a test package but I wonder what the outcome will be from deleting it by mistake. 

    My guess is that the package will continue to appear in the admin console, since you've deleted it from the root\sccmdp namespace but not from the root\SMS\site_SiteCode namespace. If you run the following command, do you see the package?

    gwmi -Namespace root\SMS\site_XXX -Class SMS_Package -Filter {PackageID = "XXX00043"}

    Wednesday, April 10, 2013 7:22 PM
  • Thanks for the reply Mike, yeah it still shows up:

    __GENUS                        : 2
    __CLASS                        : SMS_Package
    __SUPERCLASS                   : SMS_PackageBaseclass
    __DYNASTY                      : SMS_BaseClass
    __RELPATH                      : SMS_Package.PackageID="XXX00042"
    __PROPERTY_COUNT               : 47
    __DERIVATION                   : {SMS_PackageBaseclass, SMS_BaseClass}
    __SERVER                       : SERVER01
    __NAMESPACE                    : root\SMS\site_XXX
    __PATH                         : \\SERVER01\root\SMS\site_XXX:SMS_Package.PackageID="XXX00042"
    ActionInProgress               : 0
    AlternateContentProviders      :
    DefaultImageFlags              : 0
    Description                    : Testing software center on Jacob's server
    ExtendedData                   :
    ExtendedDataSize               : 0
    ForcedDisconnectDelay          : 5
    ForcedDisconnectEnabled        : False
    ForcedDisconnectNumRetries     : 2
    Icon                           :
    IconSize                       : 0
    IgnoreAddressSchedule          : False
    IsPredefinedPackage            : False
    ISVData                        :
    ISVDataSize                    : 0
    IsVersionCompatible            : True
    Language                       : EN
    LastRefreshTime                : 20130410191918.000000+000
    LocalizedCategoryInstanceNames : {}
    Manufacturer                   :
    MIFFilename                    :
    MIFName                        :
    MIFPublisher                   :
    MIFVersion                     :
    Name                           : Notepad ++
    NumOfPrograms                  : 1
    PackageID                      : XXX00042
    PackageType                    : 0
    PkgFlags                       : 16777216
    PkgSourceFlag                  : 2
    PkgSourcePath                  : \\SERVER01\d$\Packages\Software\Notepad ++
    PreferredAddressType           :
    Priority                       : 2
    RefreshPkgSourceFlag           : False
    RefreshSchedule                :
    SecuredScopeNames              : {Default}
    SedoObjectVersion              : D929BA0C-4A56-4629-9075-51EDA3AE6294
    ShareName                      :
    ShareType                      : 1
    SourceDate                     : 20130410191913.000000+000
    SourceSite                     : XXX
    SourceVersion                  : 81
    StoredPkgPath                  :
    StoredPkgVersion               : 81
    TransformAnalysisDate          : 20130311231437.000000+***
    TransformReadiness             : 3
    Version                        : 6.1.4


    Wednesday, April 10, 2013 7:26 PM
  • If you run the same command as above but pipe it to Remove-WmiObject, the package should then be deleted from the admin console. I created a test package and I can confirm that running the following command removed it from the admin console:

    gwmi -Namespace root\SMS\site_XXX -Class SMS_Package -Filter {PackageID = "XXX000XX"} | Remove-WmiObject

    Wednesday, April 10, 2013 7:31 PM
  • So what if I want to keep it? I wanted to delete 43 and ended up deleting 42 by mistake in the root\sccmdp namespace. Should I delete it from site_XXX then recreate? 
    Wednesday, April 10, 2013 7:33 PM
  • If you run Update Distribution Points for package 42, you should see it reappear in the root\sccmdp namespace.
    Wednesday, April 10, 2013 7:56 PM
  • Awesome, will give that a try. Thanks Mike!!! 
    Wednesday, April 10, 2013 7:56 PM
  • You're very welcome, glad I was able to help out.
    Wednesday, April 10, 2013 8:04 PM
  • I would just like to add that this was great information.  I had a DP get out of sync with my site server and had three packages listed in its WMI which no longer existed.

    The powershell command allowed me to remove their reference on the specific DP.

    Thank you!

    Saturday, March 15, 2014 11:39 PM