Powershell script to fix ContentLib inconsistency in WMI for ConfigMgr 2012 R2

This script repairs the "The package data in WMI is not consistent to PkgLib" and "Package can't be found in PkgLib" errors in smsdpmon.log on Distribution Points bysearching for packages that appear to be in de Content Library according to WMI but are not there and do not exist

4.5 Star
12,086 times
Add to favorites
System Center
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • when a package is missing from WMI
    2 Posts | Last post November 22, 2018
    • If there are packages exist in Contlib but don't exist in WMI, Script doesn't notify about the missing package ID.  
    • Here's a complete script that expands on Bart's script to add the reconciliation of WMI and PkgLib. 
  • Nice Script always scared to do all DPs
    2 Posts | Last post August 17, 2018
    • Great work I am little reluctant to have it run though all me DP's so I added another prompt to ask DP server name and changed the DP query added the name field to where query. Good stuff though
    • Works on 1702 - thanks!!!
  • Question: How do you re-validate after running the script?
    2 Posts | Last post January 03, 2018
    • Thanks so much for your effort in creating this script. It worked quite well in our environment.
      How do you go and re-validate all the DP's so the icon changes to a green tick now? :)
    • Just to clarify - i was wondering if you knew how to launch a content validation on all dp's without waiting for a schedule. we have over 60 dp's. and apart from waiting for the schedule or launching the smsdpmon.exe as a one off on each server i couldnt think of a way.
      have you used a script perhaps?
  • Is this supported with ConfigMgr CB 1606?
    4 Posts | Last post July 13, 2017
    • Is this supported with ConfigMgr CB 1606?
    • For what it's worth, I can confirm that it works perfectly with SCCM 1610.
      It took some work to change the PS execution policy though.
    • Can also confirm, that this works on 1610.
    • Worked for me on 1702.
  • Thanks!!!
    1 Posts | Last post September 01, 2016
    • Great script. It worked perfectly for me just wanted to say thanks for all your work!
      Andy Konczak
  • SCCM 2012 SP2
    1 Posts | Last post February 19, 2016
    • Hello Bart, is your script supported in SCCM 2012 SP2?
  • What about the site sever?
    1 Posts | Last post August 06, 2015
    • Should the script also look at the data (WMI & Content Lib) on the Site Server too? Ins't the site server the authoritative source?
  • Not valid when ones DPs have different packages?
    1 Posts | Last post April 14, 2015
    • Hey,
      Browsing the code, it seems like having two DPs with different packages (deliberately) Distributed to, is not taken into consideration, am i right?
  • Error
    2 Posts | Last post August 21, 2014
    • I get this error when running this script on my machine. I'm not sure what to make out of it. Thanks.
      Where-Object : Cannot bind parameter 'FilterScript'. Cannot convert the "sideindicator" value of type "System.String" t
      o type "System.Management.Automation.ScriptBlock".
      At C:\users\jasonf\downloads\Remove-WMIInvalidContent.ps1:56 char:48
      +             $InvalidPackages = @($result |where <<<<  sideindicator -eq '<=')
          + CategoryInfo          : InvalidArgument: (:) [Where-Object], ParameterBindingException
          + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand
    • Hi JHBPJF,
      it seems to fail on the 'where' statement in the script. I've corrected the line so it would work with Powershell v2.
      Try downloading the new script and run this one. If still any errors occur, just let me know.
  • Compare-Object: Cannot Bind argument to Parameter
    5 Posts | Last post August 20, 2014
    • Bart, when running the script, I get the following error:
      Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null.
      At C:\Remove-WMIInvalidContent.ps1:50 char:53
      +         $result = @(Compare-Object -ReferenceObject $CurrentPackageList -Differe ...
      +                                                     ~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Compare-Object], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CompareObjectCommand
      Any ideas?  We're running SCCM 2012 SP1 CU 2 on Server 2012.  Thanks for any help.
    • Hi enellison,
      This error is a result of not having any objects returned on the following WMI query in powershell: 
      Get-WMIObject -ComputerName $DistributionPointName -Namespace "root\sccmdp" -Query "Select * from SMS_PackagesInContLib"
      Where $DistributionPointName is the name of the distributionpoint that is to be checked. The script checks all of them, so I assume that either: there is one that has no packages at all. In that case, I can adjust the script so it would continue to the next distributionpoint. Or: your user account has not enough permissions to read all the objects in the SMS_PackagesInContLib class on the specific server.
      Can you verify these 2 possibilities? In the meantime I'll adjust the script to skip empty distribution points and will let you know as soon as I've posted it online.
    • Hi enellison,
      I've quickly adjusted the script to skip on empty distribution points. I just thought about another possible cause: If you are running the script on one of the distribution points, make sure you run powershell with elevated permissions (run as administrator). I hope this helps you out.
      Kind regards,
    • Bart, apologies for being so late responding.  For whatever reason I didn't get notification that you had replied.
      It seems to be working properly, though it's still passing two errors; the first one at script start, the second after each attempt to read the packages from each DP.  I've copied the images to my OneDrive for you to see (labeled in order of occurrence in script).  I've run this with elevated privileges, both as my EA Account on the domain and as 'Run as Administrator' which have full access to the site server and all DP's.  I could be doing something incorrectly, but I'm still learning PS as well.  :)
      Errors - http://1drv.ms/1nxJCzr
    • Hi enellison,
      It seems Sean has put his finger on the issue you're having here: the script will only work on ConfigMgr 2012 R2 or later as a new WMI class is being used in the script that only exists in R2. Presumably, if you would replace any entry of "SMS_ObjectContentExtraInfo" with "SMS_ObjectContentInfo" in the source of the script (use notepad or powershell ISE), it would work on ConfigMgr 2012 and ConfigMgr 2012 SP1. Although I cannot verify this as I haven't tested it.
1 - 10 of 12 Items