In large System Center Configuration Manager estates, you may encounter issues such as having to update various applications, as well as packages. For whatever reason, you will eventually need to look into these things. One long administrative task you may encounter is when you have applications/packages that are tied in various task sequence dependencies that would prevent you from removing them from the Configuration Manager console.

Unfortunately, there aren’t too many ways around such tasks besides checking the references manually in each task sequence to identify if the application/package resides here.  Of course, with the right practices you may have change logs and records of each change and step within each Task Sequence. But if not, or for an easier alternative, you can use a PowerShell script that uses WMI queries within the Configuration Manager SDK. Below is the script:

$Application = Read-Host "Name of Application"

$ApplicationResult = Get-WMIObject -NameSpace "root\SMS\Site_(SITECODE)" -Class SMS_Application | Where-Object {$_.LocalizedDisplayname -eq $Application} | Where-Object {$_.NumberofDependentTS -gt "0"}

$AppID = $ApplicationResult.CI_ID

$TSDependents = Get-WMIObject -NameSpace "Root\SMS\Site_(SITECODE)" -Class SMS_TaskSequenceAppReferencesInfo | Where-Object {$_.RefAppCI_ID -eq $AppID}

$ConfigurationManager = "C:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"

Import-Module $ConfigurationManager

Set-Location (SITECODE):

$TSNames = $TSDependents | ForEach-Object {$_.PackageID} {Get-CMTaskSequence
-Id $_.PackageID}

Write-Host $TSNames.name

PowerShell Script Breakdown

I normally like to give a breakdown of each step so you can see the development of how it all works and comes together. So I will explain how the script works, both from a single application perspective and from a bulk application perspective.

Single Application Perspective

  1. The script asks for the friendly name of the application (i.e., how it’s displayed within the Configuration Manager console).
  2. It will then pull the
    application from the SMS WMI class and filter it to where it has dependencies. As applications are revised, it records when changes are made, as well as adding to Task Sequences, Application/Package dependencies, etc.
  3. It will then pull the CI_ID for the application, which is needed in order to get the SMS WMI class to identify the application
  4. It will pull all of the Task Sequences in which the application is referenced. At this point, it shows the Package ID of the Task Sequences they belong to. Though this is a great deal, why not take this a step further by finding its exact, friendly TS Name?
  5. It will then import the module for the Configuration Manager so we can utilize its cmdlets.
  6. It will then produce a list of all of the Task Sequences in which the application is referenced by the Task Sequence’s friendly name

Bulk Application Perspective

For bulk applications, this works in the same way, but you can use a CSV file if you already have a list of all the applications. This can be pulled from the reporting side of Configuration Manager and saved as a CSV File.

You could just remove the first two lines of the script below, with something like:



$CSV = Import-CSV (Path of CSV File)

$ApplicationResult = $CSV | ForEach-Object {$_.LocalizedDisplayName} { Get-WMIObject -NameSpace "root\SMS\Site_UCL" -Class SMS_Application |
Where-Object {$_.LocalizedDisplayname -eq $App1} | Where-Object {$_.NumberofDependentTS -gt "0"}

(Package References)

This can also be used to reference packages.

I hope you find these tips useful. They’ve worked well for me. If you have PowerShell scripts that you use with System Center, please share them.