12th February 2020
Function Check-PackageWMIvsLIB
This function compare what the Distribution Point has in WMI againt ContentLib
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<# .Synopsis Compare WMI with ContentLIB locally on DP .DESCRIPTION .EXAMPLE .EXAMPLE #> Function Check-PackageWMIvsLIB { $WMIPkgList = Get-WmiObject -Namespace Root\SCCMDP -Class SMS_PackagesInContLib | Select -ExpandProperty PackageID | Sort-Object $ContentLib = (Get-ItemProperty HKLM:SOFTWARE\Microsoft\SMS\DP).ContentLibraryPath $PkgLibPath = ($ContentLib) + ‘\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 write-host Write-Host Items in WMI but not the Content Library -ForegroundColor Green Write-Host ======================================== $PksinWMIButNotContentLib Write-Host Items in Content Library but not WMI -ForegroundColor Green Write-Host ==================================== $PksinContentLibButNotWMI } |
If you want to remove WMI entry that not are in lib
1 |
Get-WMIObject -ComputerName "DPNAME" -Namespace "root\sccmdp" -Query ("Select * from SMS_PackagesInContLib where PackageID = 'PACKAGEID'") | Remove-WmiObject |
Of if you want to remove from ContentLIB
1 2 |
##Delete .ini´s in PkgLib not in WMI Remove-Item -Path "$PkgLibPath\PackageID.INI" -Confirm |
To be used at own risk…