Friday, September 19, 2014

SCCM 2012x: The package data in WMI is not consistent to PkgLib

I’ve bumped into this issue quite a few times now. The DPs seem to be fine BUT in the monitoring pane of the SCCM 2012x Console the DPs have a warning icon. When looking in the relevant log file (smsdpmon.log) on the DPs involved this entry points to the cause of it: The package data in WMI is not consistent to PkgLib.

As it turns out, it happens when some packages are removed but their entry still ‘lives’ in WMI of the DPs involved. Already the SCCM Team posted an article how to solve it, to be found here. Even though it works, it’s time consuming. So I searched for another solution and found it on the TechNet Forums.

In this thread member JT_DPS posted some powerful PS scripts, helping to solve this issue really fast. His PS scripts come in three parts.

Part I: This PS script shows you what packages are in WMI and not in the Content Library AND vice versa.

$WMIPkgList = Get-WmiObject -Namespace Root\SCCMDP -Class SMS_PackagesInContLib | Select -ExpandProperty PackageID | Sort-Object
$ContentLib = (Get-ItemProperty -path HKLM:SOFTWARE\Microsoft\SMS\DP -Name ContentLibraryPath)
$PkgLibPath = ($ContentLib.ContentLibraryPath) + "\PkgLib"
$PkgLibList = (Get-ChildItem $PkgLibPath | Select -ExpandProperty Name | Sort-Object)
$PkgLibList = ($PKgLibList | ForEach-Object {$_.replace(".INI","")})
$PksinWMIButNotContentLib = Compare-Object -ReferenceObject $WMIPkgList -DifferenceObject $PKgLibList -PassThru | Where-Object { $_.SideIndicator -eq "<=" }
$PksinContentLibButNotWMI = Compare-Object -ReferenceObject $WMIPkgList -DifferenceObject $PKgLibList -PassThru | Where-Object { $_.SideIndicator -eq "=>" }
Write-Host Items in WMI but not the Content Library
Write-Host ========================================
Write-Host Items in Content Library but not WMI
Write-Host ====================================

Part II: This PS script removes the package from WMI (using the list from Part I):

Foreach ($Pkg in $PksinWMIButNotContentLib){ Get-WmiObject -Namespace Root\SCCMDP -Class SMS_PackagesInContLib -Filter "PackageID = '$Pkg'" | Remove-WmiObject -Confirm }

Part III: This PS script removes the INI file (using the list from Part I):

Foreach ($Pkg in $PksinContentLibButNotWMI){ Remove-Item -Path "$PkgLibPath\$Pkg.INI" -Confirm }

When you revalidate the content on your DPs they should turn to green icons again.

All credits for the PS scripts in this posting go to JT_DPS.

No comments: