Finding Task Sequences referenced by Applications or Packages

First off, Thanks to Adam for getting me 80% of the way there:
https://www.asquaredozen.com/2019/02/04/finding-configmgr-task-sequences-with-invalid-references/

But I wanted to find the Task Sequences that referenced a specific Application.

So in my case, I want to Delete Google Chrome, no point with the New Edge, right?

image

Lets find those TS references:

First we need to grab the Application Info:

$Application = Get-CMApplication -Name "Google Chrome 56.0.2924.87"

Then all of the Task Sequence Info: (This can take awhile)

$TaskSequences = Get-CMTaskSequence | Where-Object { $_.References -ne $null }

Then we loop through the Task Sequences looking for where the application is referenced.

Full Code for Applications:

$Application = Get-CMApplication -Name "Google Chrome 56.0.2924.87"
$TaskSequences = Get-CMTaskSequence | Where-Object { $_.References -ne $null }

foreach ($TaskSequence in $TaskSequences)
    {
    if ($TaskSequence.References.Package -eq $Application.ModelName)
        {Write-Host $TaskSequence.Name}
    }

What does that look like:
image

And there we have it, the 2 TS’s that reference the Google App
imageimage

 

Packages are nearly the same:

Get Package Info:

$Package = Get-CMPackage -Name "WaaS_Scripts" -Fast

Full Code: (Had to change a spot in the if statement)

$Package = Get-CMPackage -Name "WaaS_Scripts" -Fast
$TaskSequences = Get-CMTaskSequence | Where-Object { $_.References -ne $null }

foreach ($TaskSequence in $TaskSequences)
    {
    if ($TaskSequence.References.Package -eq $package.PackageID)
        {Write-Host $TaskSequence.Name}
    }

In Action:
image

 

Hope you find this helpful

GARYTOWN.COM

3 thoughts on “Finding Task Sequences referenced by Applications or Packages”

  1. This is such a common issue for us, and I’m all out of Excedrin 😂. Spreading this info to my junior admins.

    The last few entries on your blog have been of tremendous help to us. For the longest time, I’ve wanted to have checks and balances in our Task Sequences. I’m happy to report that work has begun thanks to your WaaS IPU series.

    Thanks for your expertise and time, as always.

    Jay

    Reply
  2. Great article! I decided to expand on this and automate the removal or update of an application in a Task Sequence. Hope it helps someone 🙂

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.