Start a new topic

Dynamic folder sort


I have tried using the github provided powershell dynamic folder templates.

The only issue I I have is with the sorting. I have tried the advanced, basic and csv import scripts and each time it always sorts the RDP files first, followed by the sub folders?

I tried changing the sort on the end of the powershell but to no luck (using the "Type").

My attempt was:

 $newarray = $array | Sort-Object -Property type, path, name

 $hash = @{ }

 $hash.add("Objects", $newarray)

 $hash | ConvertTo-Json


Glad you got it working. Feel free to submit a PR as those script samples are all community driven...




Thanks for this. It has cleared up the issue and I have managed to fix it in the script now that it makes sense. I would recommend putting this (or equivalent, my powershell is iffy) on the end of the current github example (can submit the PR if that is easier):


$Typearray = $array | Sort-Object -Property path, name | Where-Object {$_.Type -like "Folder"}

$Connarray = $array | Sort-Object -Property path, name | Where-Object {$_.Type -notlike "Folder"}

$array = $Typearray + $Connarray

$hash = @{ }


$hash | ConvertTo-Json

If you are going to build the folder object in the json (without the path property), I suggest you put in the connections (in the right order) directly into the folder. See:

Let me know if this helps.



So if (hypothetically) I build the folder object first (put folder objects first in the JSON), will that mean that when it build the connection, it will find the path? 


In your example you have a "Path" property set. The dynamic folder will automatically build the folder structure from the path property. If you remove the path property, all items will be in the root of the dynamic folder as a flat list.

The Sort option doesn't work because the items in the dynamic folder are marked as "dynamic" and can't be modified (sorting modifies the position property).

Let me know if this helps.



When looking at the JSON from the "basic" script, there are no folder objects in the array that is converted to JSON. I can sort the connection objects fine on their own. What does the Dynamic folder do if it is given an object without a folder? 


      "Name": "server1",

      "Type": "RemoteDesktopConnectoin",

      "ComputerName": "server11",

      "Path": ""


Also the "Sort" option on the top bar doesn't seem to work on Dynamic folders (but would rather be able to provide a working config file) 


Hi Charlie,

when working with dynamic folders, the objects will be created in the same order the json lists those objects. Can you verify/check if the output (when starting the script in the powershell console) is correct?


Login or Signup to post a comment