cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ESD Web Service - Collection Cleanups

dbeckner
By Level 10 Champion
Level 10 Champion

Looking for some clarification on the Collectiion Cleanup option under the Global Subtab for deployment settings. This is from the documentation referenced below --

Remove from collection when complete?

Choose whether direct members of the SCCM collection should be removed once complete. Completion is determined using return values from SCCM specified in Program Collection Cleanup Status IDs and Task Sequence Collection Cleanup Status IDs fields on the Site Management > Settings > Deployment > ConfigMgr/SCCM 2012 tab.

 

  1. What are the SCCM specified Program Collection Cleanup Status IDs that would trigger this cleanup?
  2. Is the device cleaned from the collection for only successful installs or will a failed install also get cleaned?
  3. How does this coincide with the Collection Cleanup Interval timer? Does this timer check for specific status messages from SCCM and then trigger the ESD Web Service to cleanup the collections?

 

(1) Solution
CharlesW
By Level 12 Flexeran
Level 12 Flexeran

The "remove from collection when complete?" under deployment->global is the top-level setting used to determine if the collection should be cleaned or not when the deployment is deemed "complete". If not selected, then the device/user will not be removed from the collection.   Complete means something different depending upon the type of catalog item.. 

For applications, complete means that a success (1) status is received back from Config Mgr. By default, collections will only be cleaned on a successful install. If you also wish to have collections cleaned on a failed install, then you would go to Settings->Deployment->Config Mgr, and select the "Enable Collection Cleanup on Failure" option. One other thing to note is that a cleanup will not be performed for either a successs or failed status until monitor = 0 in the WD_PackageRequests table. 

For packages, complete means that the status returned by SCCM matches a status defined for the "Program Collection Cleanup Status ID's" setting found under Settings->Deployment->Config Mgr. This setting is essentailly a list of status's. It can include any status. In order for a cleanup to occur, a status returned by Config Mgr must match a status in the list.. Note that "Enable Collection Cleanup on Failure" option is not applicable to packages.

For task sequences, the approach is similar to packages. If you go to Settings->Deployment-> OS Deployment, you will see a setting named Task sequence collection cleanup status IDs". This is a list of status's that a are used to determine if a task sequence deployment should be cleaned up. Again, the "Enable Collection Cleanup on Failure" option is not applicable to task sequences.

The "Collection cleanup interval" timer determines the frequency at which the ESD service will check for items that need to be cleaned (based on the above criteria). It will determine this by looking at the LastStateID and LastStatusID columns in the WD_PackageRequests table.. If a match is found, then the request will be added to the list of cleanups that need to be performed on this itteration of the cleanup routine. 

It you want to know the actual query being run by App broker to determine what needs to be cleaned up, then take a look at the following:

SELECT DISTINCT sta.PackageType, pr.RequestId, pr.DateTime, pr.Cleaned, pr.RunMachine, pr.CleanedOn, 
                pr.RunMachineSuccess, pr.RunMachineError, rt.MachineName, rt.OldMachineName, 
                rt.ProcessBothInserts, rt.DeploymentCollectionId, sta.Server, sta.CollectionId, sta.Site, sta.AdvertId,  
                rt.UserName, sta.DeployTarget, vrs.MachineDomain as DomainName
                FROM vcomputer vrs WITH (NOLOCK)INNER JOIN
                WD_PackageRequests AS pr WITH(NOLOCK)
                INNER JOIN WD_WebPackages AS wp WITH(NOLOCK) ON pr.PackageID_FK = wp.PackageID
                INNER JOIN WD_RequestTarget AS rt WITH(NOLOCK) ON pr.RequestID = rt.RequestID
                INNER JOIN WD_SiteToAdvert AS sta WITH(NOLOCK) ON wp.PackageID = sta.PackageID AND PR.DeploymentTechnology = sta.DeploymentTechnology AND
                pr.RequestType = sta.Type AND(pr.LanguageID = sta.LanguageID OR sta.LanguageID = 0) ON
                vrs.MachineName = rt.MachineName WHERE ((pr.LastStateID IN (7,3,101,11,230,18,19,107,102,12,2,9,13,106,100,15,4) AND sta.PackageType NOT IN (15, 4)) OR (pr.LastStateID IN (1, 5) AND sta.PackageType = 15 AND pr.Monitor = 0) OR (pr.LastStateID IN (21,7,53,3,101,11,230,18,105,19,17,107,2,10,103,9,16,20,13,106,100,15) AND sta.PackageType = 4)) AND (wp.Clean = 1 OR pr.RequestType = 1) AND (pr.Cleaned = 0) AND (sta.Server = '<configMgrServer>') AND PR.DeploymentTechnology=8
                ORDER BY sta.CollectionID

 

this query is built dynamically, so it varies based on a number of things.. It should be enough to help you understand, however.. The comma deliminated list of status's are coming from the settings I mentioned. PackageType=15 is an application, PackageType=4 is a task sequence, and PackageType=0 is a package. Also, DeploymentTechnology=8 is configMgr.. 

One other thing that I failed to mention.. An uninstall request will always be removed from the collection when complete.. In the above query, you will see "pr.RequestType = 1",  which denotes an uninstall request.

View solution in original post

(3) Replies
CharlesW
By Level 12 Flexeran
Level 12 Flexeran

The "remove from collection when complete?" under deployment->global is the top-level setting used to determine if the collection should be cleaned or not when the deployment is deemed "complete". If not selected, then the device/user will not be removed from the collection.   Complete means something different depending upon the type of catalog item.. 

For applications, complete means that a success (1) status is received back from Config Mgr. By default, collections will only be cleaned on a successful install. If you also wish to have collections cleaned on a failed install, then you would go to Settings->Deployment->Config Mgr, and select the "Enable Collection Cleanup on Failure" option. One other thing to note is that a cleanup will not be performed for either a successs or failed status until monitor = 0 in the WD_PackageRequests table. 

For packages, complete means that the status returned by SCCM matches a status defined for the "Program Collection Cleanup Status ID's" setting found under Settings->Deployment->Config Mgr. This setting is essentailly a list of status's. It can include any status. In order for a cleanup to occur, a status returned by Config Mgr must match a status in the list.. Note that "Enable Collection Cleanup on Failure" option is not applicable to packages.

For task sequences, the approach is similar to packages. If you go to Settings->Deployment-> OS Deployment, you will see a setting named Task sequence collection cleanup status IDs". This is a list of status's that a are used to determine if a task sequence deployment should be cleaned up. Again, the "Enable Collection Cleanup on Failure" option is not applicable to task sequences.

The "Collection cleanup interval" timer determines the frequency at which the ESD service will check for items that need to be cleaned (based on the above criteria). It will determine this by looking at the LastStateID and LastStatusID columns in the WD_PackageRequests table.. If a match is found, then the request will be added to the list of cleanups that need to be performed on this itteration of the cleanup routine. 

It you want to know the actual query being run by App broker to determine what needs to be cleaned up, then take a look at the following:

SELECT DISTINCT sta.PackageType, pr.RequestId, pr.DateTime, pr.Cleaned, pr.RunMachine, pr.CleanedOn, 
                pr.RunMachineSuccess, pr.RunMachineError, rt.MachineName, rt.OldMachineName, 
                rt.ProcessBothInserts, rt.DeploymentCollectionId, sta.Server, sta.CollectionId, sta.Site, sta.AdvertId,  
                rt.UserName, sta.DeployTarget, vrs.MachineDomain as DomainName
                FROM vcomputer vrs WITH (NOLOCK)INNER JOIN
                WD_PackageRequests AS pr WITH(NOLOCK)
                INNER JOIN WD_WebPackages AS wp WITH(NOLOCK) ON pr.PackageID_FK = wp.PackageID
                INNER JOIN WD_RequestTarget AS rt WITH(NOLOCK) ON pr.RequestID = rt.RequestID
                INNER JOIN WD_SiteToAdvert AS sta WITH(NOLOCK) ON wp.PackageID = sta.PackageID AND PR.DeploymentTechnology = sta.DeploymentTechnology AND
                pr.RequestType = sta.Type AND(pr.LanguageID = sta.LanguageID OR sta.LanguageID = 0) ON
                vrs.MachineName = rt.MachineName WHERE ((pr.LastStateID IN (7,3,101,11,230,18,19,107,102,12,2,9,13,106,100,15,4) AND sta.PackageType NOT IN (15, 4)) OR (pr.LastStateID IN (1, 5) AND sta.PackageType = 15 AND pr.Monitor = 0) OR (pr.LastStateID IN (21,7,53,3,101,11,230,18,105,19,17,107,2,10,103,9,16,20,13,106,100,15) AND sta.PackageType = 4)) AND (wp.Clean = 1 OR pr.RequestType = 1) AND (pr.Cleaned = 0) AND (sta.Server = '<configMgrServer>') AND PR.DeploymentTechnology=8
                ORDER BY sta.CollectionID

 

this query is built dynamically, so it varies based on a number of things.. It should be enough to help you understand, however.. The comma deliminated list of status's are coming from the settings I mentioned. PackageType=15 is an application, PackageType=4 is a task sequence, and PackageType=0 is a package. Also, DeploymentTechnology=8 is configMgr.. 

One other thing that I failed to mention.. An uninstall request will always be removed from the collection when complete.. In the above query, you will see "pr.RequestType = 1",  which denotes an uninstall request.

Another little tidbit.. In the query, wp.Clean = 1 maps to the "remove from collection when complete?" flag set on the catalog item

This is perfect, Charles. Thank you for this information.