I have some items created using New-Item but they are automatically sorted alphabetically. I would much prefer these items to be sorted by Created date.

How do you change the sort order of items using SPE?

1 Answer 1


There are two places I can think of when it comes to changing the sort order.

Item level sort order

Select an item and change the view in the ribbon to include Standard fields. You should see something like this:


These values can be changed from the ribbon or programmatically and the value is an integer (e.g. 100, 200).

Example: The following changes an item's sort order. Assumes you know the precise order you want to achieve.

$item = Get-Item -Path "master:" -ID "{C9CB2B73-04B3-43F8-B36A-D64C77E35F79}"
$item.Fields["__Sortorder"].Value = 200
$item.Editing.EndEdit() > $null

Subitem level sort order

This is likely the option you want to go with. You don't have to worry about changing the sort manually every time, and it goes beyond a simple numerical value.

Subitem sorting context menu

Sort order menu

Example: The following sets the sort order on the parent node which results in this behavior cascading to the immediate children.

function Set-SortOrder {

        [ValidateSet("Created","Default","Display name","Logical","Reverse","Updated")]


    $subitemsSortOrderFieldId = "{6FD695E7-7F6D-4CA5-8B49-A829E5950AE9}"

    $sortValue = & { 
        switch($SortOrder) {
            "Created" {
            "Default" {
            "Display name" {
            "Logical" {
            "Reverse" {
            "Updated" {

    if($Reset.IsPresent) {
    } else {
        $item.Fields[$subitemsSortOrderFieldId].Value = $sortValue
    $item.Editing.EndEdit() > $null

$item = Get-item -Path "master:" -ID "{A1D0B3BC-CCDA-41FF-B59A-33AB84BF950B}"
# Reset the subitem sorting to Standard values
Set-SortOrder -Item $item -Reset
# Change the subitem sorting to based on Created Date
Set-SortOrder -Item $item -SortOrder Created

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.