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.


Comments (7)
  1. Anonymous says:

    got it working as suggested – thanks.

  2. 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.

  3. Anonymous says:

    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.

  4. Anonymous says:

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

  5. Anonymous says:

    I would like to request that this feature be added to MDT 2010 Update 1. 😉

    Thanks,

    Dan

  6. Konrad says:

    Thank you for the script.  It is quite helpful.

  7. RT says:

    I can’t get this script work. First it was copy-pasting weird characters from the HTML, now it errors out at oXML.transformNodeToObject. Is there a newer version? I see some recent comments on this thread–perhaps it is popular all of a sudden?

Comments are closed.

Skip to main content