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=""https://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.