Introduction
In Microsoft System Center Configuration Manager 2007 operating system deployment (OSD), there is a limitation of 4MB for task sequence XML data. This is discussed in a couple of locations:
- http://social.technet.microsoft.com/forums/en-us/configmgrosd/thread/6C4A4BB2-847B-4290-878C-3E041D9B3FD2
- http://myitforum.com/cs2/blogs/smslist/archive/2009/10/08/mssms-maximum-number-of-steps-in-an-sccm-task-sequence.aspx – Jason Sandys (ConfigMgr MVP) references the link below
- http://technet.microsoft.com/en-us/library/bb932192.aspx
The Technet document linked to above says the following:
Extremely large task sequences can exceed the 4-MB limit for the task sequence file size. If this limit is exceeded, an error is generated.
Solution: To check the task sequence file size, export the task sequence to a known location and check the size of the resulting .xml file.
Basically, the Technet troubleshooting article is suggesting that you would need to go into the ConfigMgr console, right-click a task sequence, export it to a XML file, and then pull up the file properties. That’s fine for one-off troubleshooting, but what if you had 1000 task sequences and needed to know how large all of them were? Read on to find out how!
PowerShell Solution
Rather than manually exporting each task sequence to check its size, wouldn’t it be easier to simply report on the size? Thankfully, PowerShell makes doing this quite easy. Basically, all we’re going to do in this script is:
- Retrieve a list of all task sequence packages (SMS_TaskSequencePackage)
- Retrieve a reference to each task sequence by its WMI path (required for lazy property value retrieval)
- Add a custom, dynamic “Script Property” to the task sequence object
- This dynamic property tells us how many bytes (size) the task sequence XML is made up of
- Filter for a couple interesting properties to report on
There are a couple other tricks going on in the script, for example the .NET string formatting to truncate the decimal spaces of the Size (KB) property.
<# .Synopsis Checks to see what the size of the ConfigMgr task sequence XML is. It must be less than 4 MB. .Author Trevor Sullivan (pcgeek86@gmail.com) .Notes Use at your own risk #> function Check-SccmTaskSequenceSize { param ( [Parameter(Mandatory = $true)] [string] $SccmServer , [Parameter(Mandatory = $true)] [string] $SiteCode , [string] $TaskSequenceId ) $TaskSequenceList = Get-WmiObject ` -ComputerName $SccmServer ` -Namespace rootsmssite_000 ` -Class SMS_TaskSequencePackage; # Iterate over task sequence objects foreach ($TaskSequence in $TaskSequenceList) { # Obtain reference to "raw" WMI object using its WMI path (so we get lazy properties) $TaskSequence = [wmi]($TaskSequence.__PATH); # Add a PowerShell script property to determine the size of the task sequence Add-Member ` -InputObject $TaskSequence ` -MemberType ScriptProperty ` -Name Size ` -Value { ([byte[]][char[]]$this.Sequence).Count }; # Write-Host -Object $TaskSequence.Size; # Write the updated task sequence object to the pipeline Write-Output -InputObject $TaskSequence; }; }; # USE CASE 1: Get sorted list of all task sequences # 1. Get ConfigMgr task sequences # 2. Select Name and Size (KB) properties Check-SccmTaskSequenceSize ` -SccmServer sccm01 ` -SiteCode lab ` | ` Select-Object ` -Property Name, @{ Name = 'Size (KB)'; Expression = { [Double]('{0:0.00}' -f ($_.Size/1KB)) } } break; # USE CASE 2: Get sorted (by size) list of all task sequences # 1. Get ConfigMgr task sequences # 2. Select Name and Size (KB) properties # 3. Sort by Size (KB) ascending Check-SccmTaskSequenceSize ` -SccmServer sccm01 ` -SiteCode lab ` | ` Select-Object ` -Property Name, @{ Name = 'Size (KB)'; Expression = { [Double]('{0:0.00}' -f ($_.Size/1KB)) } } ` | Sort-Object -Property 'Size (KB)'; # USE CASE 3: Get sorted (by name) list of all task sequences # 1. Get ConfigMgr task sequences # 2. Select Name and Size (KB) properties # 3. Sort by Name ascending Check-SccmTaskSequenceSize ` -SccmServer sccm01 ` -SiteCode lab ` | ` Select-Object ` -Property Name, @{ Name = 'Size (KB)'; Expression = { [Double]('{0:0.00}' -f ($_.Size/1KB)) } } ` | Sort-Object -Property Name;
This should make it much easier for you to determine which task sequences are approaching the limit! There are several examples included which show how to tweak the output Check-SccmTaskSequenceSize PowerShell function in practically useful ways:
- List all task sequence packages, with Name and Size properties
- List all task sequence packages, with Name and Size properties (sorted by Size)
- List all task sequence packages, with Name and Size properties (sorted by Name)
You will need to specify your SccmServer and SiteCode parameters yourself on the Check-SccmTaskSequenceSize function.
Let me know if you have any questions at pcgeek86@gmail.com or in the comments.
Pingback: PowerShell: Report / Check the Size of ConfigMgr Task Sequences - Chris Nackers Blog
Pingback: Chris Nackers