21 July 2021

Failed to retrieve the package list on distribution point

In the ConfigMgr console I was looking at Monitoring | Distribution Point Configuration Status.
To my surprise I found some DPs with the warning icon.
Looking into Detail for a DP, I found the message "Failed to retrieve the package list on the distribution point…"

Opening the message, it showed:



Looking in to smsdpmon.log on the DP, I found lines like "Failed to evaluate package XXX00123, Error code 0x80070002"
(Hint! Filter on "failed to evaluate package ") 

 You will find that these packages indeed doesn't exist in ConfigMgr. 

 A faster way to get a list of these packages, is of course…. PowerShell :-)
Open ISE as Administrator and paste this script:

$computername = "DP_FQDN"
$WMIPkgList = Get-WMIObject -NameSpace Root\SCCMDP -Computername $computername -Class SMS_PackagesInContLib | Select -ExpandProperty PackageID | Sort-Object
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computername) $RegKey= $Reg.OpenSubKey("SOFTWARE\\Microsoft\\SMS\\DP")
$ContentLib = $RegKey.GetValue("ContentLibraryPath")
$PkgLibPath = ($ContentLib) + "\PkgLib"
$drive = $PkgLibPath.SubString(0,1)
$PkgLibPath = $PkgLibPath.Replace(($drive+":\"),("\\"+$computername+"\"+$drive+"$\")) $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 Delete these items from WMI:
$PksinWMIButNotContentLib
Write-Host Delete .INI files of these packages from the PkgLib folder: $PksinContentLibButNotWMIcls


This will provide you with a list of packages that exist in WMI on DP but not in ConfigMgr. 

 To delete these packages from WMI on the DP…. PowerShell to the rescue :-)
(you need an elevated prompt or ISE as administrator) 

Get-WMIObject -ComputerName "DPNAME" -Namespace "root\sccmdp" -Query ("Select * from SMS_PackagesInContLib where PackageID = 'PACKAGEID'") | Remove-WmiObject 

When all packages are deleted from the DP, run SMSDPMON.EXE on the DP.