Export SCCM Task Sequence Dependencies Powershell - Featured Image

Introduction

Before starting any operating system deployment via SCCM, you will need to verify that all dependencies for the Task Sequences have been fully distributed to your Distribution Points.

In this blog post, I provide an SCCM Task Sequence Powershell script which you can use to export all the dependencies of a specific Task Sequence.

The script uses the Get-CMTaskSequence CMDlet provided in the SCCM Powershell module.

What are Task Sequence dependencies in SCCM?

Task Sequence dependencies are the packages, applications, or OS images that need to be available on the local Distribution Point in order for operating system deployment to start.

How can I see which dependencies I have for a Task Sequence in SCCM?

If you want to view which dependencies you have for a specific Task Sequence in SCCM, open the SCCM console and go to:

Software Library -> Operating Systems -> Task Sequences.

Once you have selected your Task Sequence, go to the References tab, and you will see a list of all the dependencies:

How to export a list of Task Sequence dependencies in SCCM using Powershell

1. Run the Powershell script using:

\Export-Task_Sequence_Dependencies.ps1 -TSID <Task Sequence ID>

2. Open dependencies.csv to find the dependencies for the given Task Sequence.

You can also find the script in the TechNet Gallery.

<#
.SYNOPSIS
Exports a CSV of all the depedencies for a given Task Sequence.
    
.DESCRIPTION
Exports a CSV of all the depedencies for a given Task Sequence.

Author: Daniel Classon
Version: 1.0
Date: 2015/05/12
    
.EXAMPLE
.\Export-Task_Sequence_Dependencies.ps1 -TSID P0000061
Exports a CSV of all the depedencies for Task Sequence with ID P0000061.
    
.DISCLAIMER
All scripts and other powershell references are offered AS IS with no warranty.
These script and functions are tested in my environment and it is recommended that you test these scripts in a test environment before using in your production environment.
#>

[CmdletBinding()]

param(    
    [Parameter(Mandatory=$True, Helpmessage="Provide the Task Sequence Package ID")]
    [string]$TSID
)

Begin {
    #Checks if the user is in the administrator group. Warns and stops if the user is not.
    if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
        Write-Warning "You are not running this as local administrator. Run it again in an elevated prompt." ; break
    }
    try {
        Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)
    }
    catch [System.UnauthorizedAccessException] {
        Write-Warning -Message "Access denied" ; break
    }
    catch [System.Exception] {
        Write-Warning "Unable to load the Configuration Manager Powershell module from $env:SMS_ADMIN_UI_PATH" ; break
    }
}
Process {
    $SiteCode = Get-PSDrive -PSProvider CMSITE
    Set-Location -Path "$($SiteCode.Name):\"
    $TS = Get-CMTaskSequence -TaskSequencePackageId $TSID

}
End {
    Set-Location -Path $env:SystemDrive
    $TS.references | select Package | Export-CSV "dependencies.csv"
}

References

Related posts

Subscribe to newsletter:

If you want to receive the latest news for MEMCM, Windows 10, and Powershell, please subscribe to my monthly newsletter!

3 COMMENTS

  1. Hello

    I would like his SVP when we have the number 4 in the column of References

    Does this mean that the application is used elsewhere and 4 times in SCCM?

    If so is there a powershell script that allows you to retrieve all applications that are not using (0)
    Thank you for your help

  2. Unfortunately the “References” property does not list packages in task sequence steps that are disabled.
    That can cause OSD deployment failures in resolving task sequence dependencies if say, someone was doing package cleanup and this script reported that package was not in use and they decided to deleted it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here