How to find Settings Preventing Application Deletion in ConfigMgr

Today my co-worker was attempting to delete an old application and got blocked with the following message message and I wanted to document it for future reference.

A Square Dozen Image
Configuration Manager cannot delete this application because other applications or task sequences reference it or it is configured as a deployment.

 1Configuration Manager cannot delete this application because other applications or task sequences reference it or it is configured as a deployment.
 4Number of dependent applications: 0
 5Number of active deployments: 1
 6Number of dependent task sequences: 9 
 7Number of virtual environments:0
 8Number of settings:1
10To view the dependent applications, open the application properties, and then click the References tab.
11To view the active deployments, select the application, and then select the Deployments tab in the details pane.
12To view the dependent task sequences, select the task sequences in the Operating Systems node, and then select the References tab in the details pane.
13To view the virtual environments, open the application properties, and then click the References tab.

Number of Settings = Number of Configuration Items

The first items listed are easy to find and the dialog even provides instructions for finding the blocking references to the application. The last item in the list was the confusing one. Number of settings: 1. There is no information in the dialog to help find out what Settings refers to. To find the answer I opened up smsprov.log from the site server logs to see which query was being run. This is a great technique for finding out where data is coming from within the ConfigMgr console. As you can see in the screenshot, I found the WMI class being queried - SMS_ApplicationLatest.


To query this in WMI the query would be:

2FROM SMS_ApplicationLatest 
3WHERE ModelName='ScopeId_FC07EA7F-55AD-47CC-90AA-2A3E907188DF/Application_dda94e21-8237-4403-ba24-0f36ce2f9213'

The equivalent query in SQL would use a ConfigMgr SQL function. If you were building a report, you’d want to use the RBAC function fn_rbac_ListLatestApplicationCIs but to keep this simple, we will use the non-RBAC function fn_ListLatestApplicationCIs.

2FROM fn_ListLatestApplicationCIs(1033) 
3WHERE modelname = 'ScopeId_FC07EA7F-55AD-47CC-90AA-2A3E907188DF/Application_dda94e21-8237-4403-ba24-0f36ce2f9213'

The result of this query includes the NumberOfSettings column which populates the count for Number of settings: in the error message.

A Square Dozen Image
fn_ListLatestApplicationCIs - NumberOfSettings

Unfortunately, this function only provides the summarized count for this column, we need the underlying table(s) in order to determine the source of this count.

STOP! The following should only be done in your test/lab environment. I do not recommend doing this in production since you could unintentionally break things. I take no responsibility for your actions.

In SSMS, you can right click on the function and open it in the editor to see what queries are being used to generate the output for the function. This was my next step.

This function is quite complex but searching for NumberOfSettings made it easy to find the source tables in the queries.

Within the console there are Configuration Items that go with Configuration Baselines, but within the ConfigMgr backend, Configuration Items can be any object within the database. My next step was to determine what a RelationType of 21 mapped to. I quickly found another view that gave me a full list.

 2FROM v_CIRelationTypes
 5RelationType	Description	IsRecursive
 61	Bundled	1
 72	Required	0
 83	Prohibited	0
 94	Optional	0
105	Derived	1
116	Superseded	1
127	Self	0
138	Reference	0
149	AppToDTReference	0
1510	AppDependence	1
1611	Intention	0
1712	Platform	0
1813	GlobalConditionReference	0
1915	ApplicationSuperSeded	1
2016	ApplicationType	0
2117	ApplicationHost	0
2218	ApplicationInstaller	0
2319	SupersedOrDependent	1
2420	VirtualEnvironmentReference	0
2521	AppDCMReference	0
2622	DeploymentTypeToPolicyTemplateReference	0
2723	CIInheritanceRelation	0

As you can see on line 23, RelationType 21 = AppDCMReference. (Desired Configuration Management) which is part of your Compliance Settings in the for ConfigMgr. You may also notice that RelationType 9 was also used in the query. This was the relationship mapping the Application to the Application Deployment Type. Then the Application Deployment Type was mapped to the Configuration Item.

Building a Query to map Applications to DCM Configuration Items

From there I was able to build a simple query to use to pinpoint the Configuration Item that is preventing the application from being deleted.

 1DECLARE @LocaleID int, @ApplicationName nvarchar(500)
 4	@LocaleID = 1033,
 5	@ApplicationName = 'MDOP MBAM 2.5 SP1'
 8	lci.DisplayName  AS ApplicationName,
 9	lci.ci_id as ApplicationCIID,
10	loc.DisplayName as CIName
12	fn_ListLatestApplicationCIs(1033) lci INNER JOIN
13	vSMS_CombinedConfigurationItemRelations appToDTRel ON lci.CI_ID = appToDTRel.FromCI_ID
14	inner join vSMS_CombinedConfigurationItemRelations cidt on appToDTRel.ToCI_ID=cidt.FromCI_ID and appToDTRel.RelationType=9
15	inner join vSMS_CombinedConfigurationItemRelations settingsToDTRel on settingsToDTRel.ToCI_ID = cidt.FromCI_ID 
16	inner join v_ConfigurationItems settingsCI on settingsToDTRel.FromCI_ID=settingsCI.CI_ID and settingsToDTRel.RelationType=21 and settingsCI.IsTombstoned=0   
17	inner join fn_LocalizedCIProperties(@LocaleID) as loc ON loc.CI_ID = settingsCI.CI_ID
19	lci.DisplayName = @ApplicationName

In this case, we had to look at the revision history for a CI for another application and delete an older version of the CI where the old application was being referenced. We had created a CI that we used as a template for several others and each time we changed from the template app to the new app, the template app was left in the revision history, making it less than obvious where it was hiding.

Extending the Console

If you want to take it to the next level and add a custom pane to your ConfigMgr console, you can use this WMI query as the starting point then use this great post by Ioan Popovici to build the custom extension More info on the WMI Class SMS_CIRelation_Flat can be found here

 3	SMS_ApplicationLatest INNER JOIN
 4	sms_CIRelation_flat AS appToDTRel ON SMS_ApplicationLatest.CI_ID = appToDTRel.FromCIID INNER JOIN
 5	sms_CIRelation_flat AS cidt ON appToDTRel.ToCIID = cidt.FromCIID INNER JOIN
 6	sms_CIRelation_flat AS settingsToDTRel ON settingsToDTRel.ToCIID = cidt.FromCIID INNER JOIN
 7	SMS_ConfigurationItem AS settingsCI ON settingsToDTRel.FromCIID=settingsCI.CI_ID
 9	SMS_ApplicationLatest.ModelName='ScopeId_FC07EA7F-55AD-47CC-90AA-2A3E907188DF/Application_dda94e21-8237-4403-ba24-0f36ce2f9213'
10	and appToDTRel.RelationType = 9
11	and settingsToDTRel.RelationType=21


Sometimes things within ConfigMgr can be a mystery but with a little bit of digging you can solve the puzzle. If you ever see the message above when deleting an application, just remember that Settings refers to Configuration Items. I hope you found this helpful - if nothing else, I’ve got this documented for the next time I need to deal with it.