Finding ConfigMgr Task Sequences with Invalid References

Last week, my coworker was in the process of cleaning up some old versions of our core applications and ran into an issue deleting an app. When she attempted to delete it, she got a message indicating that the application was used in a Task Sequence. Unfortunately, the dialog doesn’t offer any additional information as to WHICH Task Sequence is using the application. She asked me for help and here’s what we ended learning.

Disabled TS References

So the first thing we learned is that if you disable the Install Application step in a Task Sequence, the application reference gets removed from the Task Sequence References tab. This is good and bad. It’s good because it won’t prevent an application from being deleted. It’s bad because there’s no way to find out if it exists in any Task Sequences from the console.

Invalid Applications

We have around 75 Task Sequences currently. We keep archives of old ones plus we use several nested ones so they add up. I thought I could quickly find the reference manually so I started out manually clicking through each Task Sequence with the References tab selected so I could quickly skim through the references. Within a few minutes, I was done and was unable to find the reference. I thought that maybe the Application was disabled in the TS but based on the way Disabled works, we should have been able to delete.

I ended up running some PowerShell commands (script below) and was able to find the Task Sequence where the application was referenced. When I opened the Task Sequence, I received an alert indicating that one of my application references was invalid. During the cleanup process, the deployment type had been deleted from the application. While you can’t delete an application if it’s referenced by a Task Sequence, you CAN delete it’s deployment types, which then breaks the reference apparently.

Missing deployment type breaks step.

One or more of selected applications is not valid

Scripting the Fix

If you launch the PowerShell console from the ConfigMgr console, you can run these commands to find out useful information about your Applications and their references.

Get Applications

This command will return the list of applications and their counts of places they are used. For Task Sequences, you would look for NumberOfDependentTS.

Get Task Sequences

This command will get all Task Sequences that have references to any Applications/Packages/Etc.

Get Applications that have Dependent Task Sequences

This command will return all applications that have Dependent Task Sequences but don’t have any Deployment Types. Note, you can change out Application for Package in any of these commands.

Finding the Task Sequences that References the invalid applications.

Run this to find all Applications and Task Sequences that don’t have a deployment type and have an invalid reference.

Summary

From here, I just manually went into the Task Sequence and resolved the issue. I’m haven’t scripted Task Sequence stuff enough yet to feel comfortable just blindly removing the invalid reference. Hopefully this gets you through the hard part.

Well that’s all I’ve got for this one. Hopefully you find it useful. I’d like to thank Maurice Daly for his post on cleaning up applications. It saved me a few steps on putting everything together.

You Might Also Like

No Comments

Comment

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

1,519