Sorting Scripts in Automation

Product: PowerShell Universal
Version: 3.3.4

Is there an option for default sorting of Scripts in Automation?
By default they seem to be sorted in order of when they were created.
I would like to be able to have the default sorting option for alphabetical by Name. Would improve usability for my internal staff.

Thanks

1 Like

easiest way would be to sport the scripts.ps1 file yourself. default location is C:\ProgramData\UniversalAutomation\Repository.universal

Thanks for the tip.
I had tried this previously and didn’t see any difference. Tried again but restarted the service and they are re-ordered now.
While not a solution, a stopgap until something is implemented.

For anyone else playing along, I wrote up a function to assist in doing this.



function Sort-FileContents {
    param (
        $InputFile,
        $OutputFile
    )
    
    $HashSet = new-object System.Collections.Generic.HashSet[string]
    $reader = [System.IO.File]::OpenText($InputFile)
    try {
        while ($null -ne ($line = $reader.ReadLine())) {
            $null = $HashSet.Add($line)
        }
    }
    finally {
        $reader.Close()
    }

    $ListArray = new-object system.collections.generic.List[string] $HashSet
    $ListArray.Sort()

    try {
        $File = New-Object System.IO.StreamWriter $OutputFile
        foreach ($LineString in $ListArray) {
            $File.WriteLine($LineString)
        }
    }
    finally {
        $File.Close()
    }
}