Find Task Sequences targeted to a device via PowerShell


The following Get-WMIObject query will return all Task Sequences that are deployed against a device in ConfigMgr 2012.

Feed in a variables.

$ResourceName = 'targeted device'
$SiteServer = 'hostname of the site server'
$SiteCode '3 digit site code'

Then run the following command:

Get-WMIObject -ComputerName $SiteServer -Namespace root/SMS/site_$SiteCode-Query "SELECT di.* FROM SMS
_FullCollectionMembership fcm, SMS_DeploymentInfo di WHERE fcm.Name = '$ResourceName' and di.TargetSecurityTypeID = '20
' and di.CollectionID = fcm.CollectionID"

4 comments

  1. Hi Paul,
    During testing, I deployed a task sequence of 7 applications as an available deployment in Software Center (SCCM 2012) to a Windows 7 32-bit environment. It deploys fine and when you run it everything installs as expected. It then shows as ‘Installed’ in Software Center. For further testing of some changes to the task sequence, I manually uninstalled the 7 applications from the test computer, in preparation for redeploying the task sequence. However, the original instance remains in the ‘Installation Status’ tab of Software Center with ‘Installed’ status. The redeployment is correctly ‘not detecting’ all 7 apps in AppDiscovery.log and correctly evaluating in AppIntentEval.log, but it fails to re-appear in Software Center as ‘available’. I have tried recycling all the local client policies and rebooting but with no success. How can I get rid of the ‘installed’ status in Software Center?

    thanks
    Nigel

    1. Nigel – try the following PS on your client

      Get-WmiObject -Namespace "root\ccm\scheduler" -Class ccm_scheduler_history | where {$_.ScheduleID -like "*CMRA0002*"} | ft ScheduleID

      Get-WmiObject -Namespace "root\ccm\scheduler" -Class ccm_scheduler_history | where {$_.ScheduleID -like "*CMRA0002*"} | Remove-WmiObject

      Get-Service | where {$_.Name -eq "CCMExec"} | Restart-Service

      Replace CMRA0002 with the PackageID of your Task Sequence.

      This will redeploy the TS

      1. Thanks for that, Paul.
        I found a record of my package id in the wmi database with your script and successfully removed it, but it remains in Software Center as ‘installed’ and redeploying the TS does not make it reappear as ‘available’, even after recycling the policies. Any other places where there might be a record of it that I might need to delete?

        cheers
        Nigel

      2. If you are testing then delete the TS deployment run a policy update and then create a new deployment otherwise it’s probably just going to take some time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s