Calculate the Total Size of all Packages in a ConfigMgr Task Sequence

Today I got an interesting question – Is it possible to gather the sizes for all packages referred by a OS deployment task sequence?  I have a script that will find all package sizes for any group of packages you select, but not specifically for a task sequence.

But I found it can be done quite easily.  Simply enter your task sequence name and your site code, and the script will return all the packages referenced in that task sequence with their package sizes, and also give the total count and total size.

Capture

 


$TaskSequenceName = "Windows OS Deployment x64"
$SiteCode = "ABC"

$TSID = Get-WmiObject -Namespace ROOT\sms\Site_$SiteCode -Query "Select PackageID from SMS_PackageStatusDetailSummarizer where Name = '$TaskSequenceName'" |
    Select -ExpandProperty PackageID

$PKGs = Get-WmiObject -Namespace ROOT\sms\Site_$SiteCode -Query "Select * from SMS_TaskSequencePackageReference where PackageID = '$TSID'" | 
    Select @{N='PackageName';E={$_.ObjectName}},@{N='Size (MB)';E={$($_.SourceSize / 1KB).ToString(".00")}} | Sort PackageName

$Stats = $PKGs | Measure-Object "Size (MB)" -sum
$PKGs | Out-GridView -Title "Packages in ""$TaskSequenceName""   |   Total Packages: $($Stats.Count)   |   Total Size of Packages: $(($Stats.Sum / 1KB).ToString(".00")) GB"

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s