SCCM. Distribution Points Challenges. Part 1

I recently started a new contract to support a large SCCM environment. During infrastructure health check I found package distribution didn’t work well. Some packages stuck a year ago, some of them just a few days, several DPs didn’t report back but nevertheless they received all packages and distributed them to workstations – false faulty DP but broken site servers.  Usual stuff for large systems management environment smile_teeth.

How to fix it?

Of course I could refresh packages on faulty DPs using SCCM console

Go to Site Database | Computer Management | Software Distribution | Package, find the package (it may be in a folder/subfolder), click "+" to expand it, select "Distribution Points", right click on a DP you want to refresh, and select "Refresh"

but report #141 ("All active package distributions" http://sccmservername/smsreporting_XYZ/Report.asp?ReportID=141)  didn’t inspire me to do it in this way – I had six thousand records in the report. Too much you think. Well… I am looking after 1500 distribution points and  thousand packages. So when just one package gets stuck on scheduled update or a new DP fails to unpack PCK files I get thousand active distribution packages. Anyway if I started to fix it manually it would be racing against time. That’s not for me – I am too lazy for it smile_wink.

And sometimes SCCM can’t fix such issues by refreshing DPs.  Another option is to update all distribution point by increasing a version number of the package but it doesn’t guaranty that all DPs will get the package this time and potentially the package delivery can fail on others DPs.

"Dirty feet" to database

I know, I know T-SQL query solutions are not supported by Microsoft but it helps me with SMS 2003 and SCCM 2007.

You can download the script from here.

———————————————————————

— SCCM Resend Packages ver 1.0

— File Name: SCCMResendPkg.sql

—    by Oleg Gaponov 9 Oct 2008

— Resends SCCM package(s) to Distribution Point(s)

— Variables to modify: @Packages, @Sites, @ForceToResend

— If @Packages = ‘%’ and @Sites = ‘%’ resends all "stuck" package distributions (Report # 141)
— With @ForceToResend = 1 setting it resends only one package (first one if use template ‘%’) regardless distribution status.

— Ref:
—    None

— Copyright Oleg Gaponov (C) . All rights reserved
http://bridgingitgaps.spaces.live.com
— Oleg.Gaponov [at] live.com

——————————————————————–

DECLARE @Packages AS VARCHAR(8), @Sites AS VARCHAR(3), @ForceToResend AS INT

— Parameters to modify —

SET @Packages = ‘XYZ1234%’
SET @Sites =
‘b%

— set 0 to resend to ‘faulty’ DPs only; set 1 – resend regardless of the package status
— note: to avoid pushing ALL packages to ALL DPs this parameter works for the first packages only
SET @ForceToResend = 0

— End of the parameters part —    

DECLARE Cur_PkgStatus CURSOR FOR 
SELECT ID, Type, SiteCode, PkgServer, Status, SourceVersion FROM PkgStatus
WHERE Type IN (1,2) — AND PkgStatus.SiteCode <> XYZ’ — put the central site code here
AND PkgStatus.ID like @Packages
AND PkgStatus.SiteCode like @Sites
FOR UPDATE OF SourceVersion , Status

DECLARE @PkgID AS VARCHAR(8), @Type AS INT, @SiteCode AS VARCHAR(3), @PkgServer AS VARCHAR(255),  @Status AS INT, @SourceVersion AS INT
DECLARE @PrevPkgID AS VARCHAR(8), @PkgVersion AS INT, @PkgPriority AS INT, @PkgSize AS INT

OPEN  Cur_PkgStatus
FETCH NEXT FROM Cur_PkgStatus INTO @PkgID, @Type, @SiteCode, @PkgServer, @Status, @SourceVersion
SET @PrevPkgID = @PkgID

SELECT @PkgVersion = SourceVersion,  @PkgPriority = Priority, @PkgSize = SourceCompSize FROM SMSPackages WHERE PkgID = @PrevPkgID
IF @PkgSize > 500000  SET @PkgPriority = 2 — sending priority set to medium
IF @PkgSize > 1000000 SET @PkgPriority = 3 — sending priority set to low (after hours)
IF @ForceToResend = 1 SET @PkgVersion = 9999  — to resend to all DPs

WHILE @@FETCH_STATUS = 0 BEGIN
  IF @Type = 1 AND (@Status <> 2 OR @SourceVersion <> @PkgVersion)   BEGIN
    PRINT @PkgID + ‘ ver.’ +  CONVERT ( VARCHAR(255),@PkgVersion) + ‘ , size = ‘+ CONVERT ( VARCHAR(255),@PkgSize) +’ , priority = ‘+ CONVERT ( VARCHAR(255),@PkgPriority)
    PRINT ‘Resend to DP ‘ +  @PkgServer+’ on ‘ + @SiteCode + ‘ site ‘
    UPDATE PkgServers SET RefreshTrigger  = 1, UpdateMask = 4, Action = 1
         WHERE PkgID = @PkgId  AND SiteCode = @SiteCode   — AND NALPath = @PkgServer 
         AND  @PkgServer = SUBSTRING(NALPath, CHARINDEX(‘\\’, NALPath) + 2,
                                 CHARINDEX(‘\’, NALPath, CHARINDEX(‘\\’, NALPath) + 2) – CHARINDEX(‘\\’, NALPath) – 2 )
    UPDATE PkgStatus SET SourceVersion = 0, Status =0  WHERE CURRENT OF Cur_PkgStatus
    INSERT PkgNotification (PkgID, Priority, TimeKey)  VALUES (@PkgID,  @PkgPriority , GetDate())
  END
  ELSE IF @Type =2 AND (@Status <> 3 OR @SourceVersion <> @PkgVersion) BEGIN
    PRINT @PkgID + ‘ ver.’ +  CONVERT ( VARCHAR(255),@PkgVersion) + ‘ , size = ‘+ CONVERT ( VARCHAR(255),@PkgSize) +’ , priority = ‘+ CONVERT ( VARCHAR(255),@PkgPriority)  PRINT ‘Resend to  ‘+ @SiteCode + ‘ site NAL ‘ + @PkgServer

    UPDATE PkgServers SET RefreshTrigger  = 1, UpdateMask = 4, Action = 1 WHERE PkgID = @PkgId AND SiteCode = @SiteCode  AND NALPath = @PkgServer
    UPDATE PkgStatus SET SourceVersion = 0, Status =0  WHERE CURRENT OF Cur_PkgStatus
    INSERT PkgNotification (PkgID, Priority, TimeKey)  VALUES (@PkgID,  @PkgPriority , GetDate())
  END

  FETCH NEXT FROM Cur_PkgStatus INTO @PkgID, @Type, @SiteCode, @PkgServer, @Status, @SourceVersion
  IF @PkgID <> @PrevPkgID BEGIN
    SET @PrevPkgID = @PkgID
    SELECT @PkgVersion = SourceVersion,  @PkgPriority = Priority, @PkgSize = SourceCompSize FROM SMSPackages WHERE PkgID = @PrevPkgID
    IF @PkgSize > 500000  SET @PkgPriority = 2 — sending priority set to medium
    IF @PkgSize > 1000000 SET @PkgPriority = 3 — sending priority set to low (after hours)

  END
END

CLOSE Cur_PkgStatus;
DEALLOCATE Cur_PkgStatus;

— EOF —

You can put specific site name and/or package code or use templates to send multiple packages to DPs.  The query doesn’t trigger package sending if it was already delivered unless you set @ForceToResend = 1.

imageI’ve noticed sometimes it doesn’t work if you pushing an "old" package from the central site to secondary ones and have "Send package from the nearest site in the hierarchy" switched on. I had to resend such packages to the primary sites. That’s because the central site knows that the primary already has a compressed copy of the package and sends just instructions but not the package.  Why that’s happened I don’t know yet. I think someone deleted old PCK files – going to check it but I may need another script for it

CheerZ
Oleg

Advertisements

About oleggap

IT Pro
This entry was posted in SCCM. Bookmark the permalink.

2 Responses to SCCM. Distribution Points Challenges. Part 1

  1. deven says:

    Hi, Would like to know how many PXE service point you have in ur site to support infrastructure…..and can we have pxe boot imgae installed on DP/BDP rather on PXE share. if u can email me on devknowledge@gmail.com wud b great as i dont blog much was just serching for answer and found ur blog …very helpful plz do a favour. Thanks

  2. Oleg says:

    Hi,You can distribute PXE image to DP but WDS/PXE Point would not use it. So no point to do it. Any reason why you don\’t want to be it on PXE shares?

Comments are closed.