Welcome to TechNet Blogs Sign in | Join | Help

Sorting MDT's lists of applications, task sequences, patches, etc.

It seems to be a common request:  You want the MDT Deployment Wizard to show items sorted alphabetically.  So here's a simple script to do that:

' First parameter:  XML file name
' Second parameter: name of the element to sort on, e.g. Name (case-sensitive)

If WScript.Arguments.Count <> 2 then
    WScript.Echo "Usage: cscript.exe SortXML.vbs <filename> <node to sort on>"
    WScript.Echo "Sample: cscript.exe SortXML.vbs C:\Distribution\Control\Applications.xml Name"
    WScript.Quit
End if

' First load the specified XML file
Set oXML = CreateObject("MSXML2.DOMDocument")
oXML.PreserveWhiteSpace = true
oXML.Async = false
If not oXML.Load(WScript.Arguments(0)) then
    WScript.Echo "Unable to load XML file " & WScript.Arguments(0) & ", aborting"
    WScript.Quit
End if

' Populate the XSL transform

Set oXSL = CreateObject("MSXML2.DOMDocument")

oXSL.loadXML "<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" >" & _
    "    <xsl:template match=""@*|node()""><xsl:copy><xsl:apply-templates select=""@*|node()""><xsl:sort select=""" & WScript.Arguments(1) & """ /></xsl:apply-templates></xsl:copy></xsl:template>" & _
    "</xsl:stylesheet>"

' Transform the XML and save it back

oXML.transformNodeToObject oXSL, oXML
oXML.Save WScript.Arguments(0)

Save this as "SortXML.vbs" and then you can do things like this (substituting appropriate paths for your environment):

cscript.exe SortXML.vbs C:\Distribution\Control\Applications.xml FullName

cscript.exe SortXML.vbs C:\Distribution\Control\TaskSequences.xml Name

cscript.exe SortXML.vbs C:\Distribution\Control\Drivers.xml Name

For safety, make sure you have a backup copy of the file before you do this.  And don't do this while the Deployment Workbench is running, as it could overwrite your sorted file.

Published Friday, June 20, 2008 9:55 PM by mniehaus

Comments

# re: Sorting MDT's lists of applications, task sequences, patches, etc.

Tuesday, June 24, 2008 1:44 AM by Konrad

Thank you for the script.  It is quite helpful.

# re: Sorting MDT's lists of applications, task sequences, patches, etc.

Friday, June 27, 2008 3:50 PM by jparekh73

During deployment we can present the user with options to install applications.  Is it possible to be able to call that list of applications dialog post deployment.  We heard from clients it would be nice to be able for someone to call a script to bring that up again to install other apps later if they wanted to.

# re: Sorting MDT's lists of applications, task sequences, patches, etc.

Monday, June 30, 2008 6:55 PM by mniehaus

Yes, you can create a task sequence using the "custom" task sequence template that does this.  The only limitation:  If you need to perform any reboots, this custom task sequence (initiated from the full OS by mapping a drive to the deployment share and running LiteTouch.vbs) doesn't set up the autologon or startup group entries necessary to resume the task sequence, so you'd have to run LiteTouch.wsf again manually or add an additional step to set up the machine to do autologon.

# re: Sorting MDT's lists of applications, task sequences, patches, etc.

Monday, July 07, 2008 2:30 PM by jparekh73

What if I just want the dialog up for the user that shows the list of apps to install after MDT has finished?

# re: Sorting MDT's lists of applications, task sequences, patches, etc.

Friday, July 18, 2008 1:13 PM by jparekh73

got it working as suggested - thanks.

Anonymous comments are disabled
 
Page view tracker