Tuesday, 24 September 2019

SCCM application Dependency and Supersedence








How do we get an SCCM application's dependency and supersedence details using Powershell?

When we need to retire an SCCM application from console we need to see the application's dependency and supersedence information, getting this information is little difficult through Powershell as there is no direct property available to call the details on get-cmapplication cmdlet. Instead, there is a property called "SDMPackageXML" where all these information's are available. Since the information is in XML format we need to deserialize the XML to read the information properly. 
Please follow the below steps to get the SCCM application dependency and supersedence information through PowerShell

Application dependency 

Below is the property of an application in SCCM (Adobe Reader DC 11)















Once we select the application, then go to deployment tab property to get the application dependency as shown below. As per the below example, "Acrobat Reader DC 10" is the dependent application




















Below is the PowerShell cmdlet to get the application details.

Get-CMApplication "Adobe Reader 11.0.0.0"

Please note the "SDMPackageXML" property from the below result.




















Now we need to deserialize the XML format to read the information easily.
Serializes or deserializes an application between the C# instance and the XML format, see the below link for more information.
https://docs.microsoft.com/en-us/previous-versions/system-center/developer/jj154378(v%3Dcmsdk.12)
$XMLDeS = [Microsoft.configurationmanagement.applicationmanagement.serialization.sccmserializer]::DeserializeFromString($Application.SDMPackageXML,$true)
$XMLDeS.DeploymentTypes
From the below result, we can see application dependency and supersedence information.

The information which is required for us is inside the "Operands " property. Go to operands property using the below cmdlet.

$XMLDeS.DeploymentTypes.dependencies.Expression.Operands

















From the above information, we can see the dependent application information, but the problem is Instead of application name we got the application scope ID and Application logical name. Now the question is how do we get the application information using scope ID and Logical Name? It is easy as we can see the application scope ID and logical name is visible in get-cmapplication property. 
From the below example we can see both information is available in "Model" property in a combined format using a forward slash (/)
Get-CMApplication "Adobe Reader 11.0.0.0"


Now we need to join the application scope ID and logical name to search the application using the model name, follow the below cmdlet


$GetModel = $XMLDeS.DeploymentTypes.dependencies.Expression.Operands
$ModelName = $GetModel.DeploymentTypeAuthoringScopeId + '/' + $GetModel.ApplicationLogicalName
$ModelName









As per the above example, we got the application model name, now we need to seach the application using get-cmapplication cmdlet as showing below


Get-CMApplication | Where-Object {$_.ModelName -eq "$ModelName"}

now we will get the dependency application name

Application Supersedence.

Below is the application supersedence option of an application (Right-click on the application)













we need to follow the same steps here to deserialize the XML format

$XMLDeS = [Microsoft.configurationmanagement.applicationmanagement.serialization.sccmserializer]::DeserializeFromString($Application.SDMPackageXML,$true)
$XMLDeS.DeploymentTypes

From the below result, we can see application supersedence information.
















We need to select the supersedence option to see more details as shown below.

$XMLDeS.DeploymentTypes.supersedence


















We need to filter the expression property to identify the superseded applications name as shown below.

$XMLDeS.DeploymentTypes.supersedence.expression.















Now we need to follow the same process used to get the dependency application name here.

Since we are expecting multiple supersedence for the same application, we need to pass the application through a foreach loop as shown below to fetch all the superseded application list






















We got the two supersedence application details with a semicolon-separated value.