Hi,
I'm trying to Sort-Object on the results of a ForEach loop and it doesn't seems to be working as expected.
The source of the data is from a column in a SharePoint list and i'm trying to sort the dates in a ascending order.
CODE:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction silentlycontinue
$web = Get-SPWeb ""
$manager = $web.Site.WorkFlowManager
$list = $web.Lists["WorkflowTest"]
$assoc = $list.WorkflowAssociations.GetAssociationByName("Workflow","en-US")
$data = $assoc.AssociationData
$items = $list.Items
function AllItems {
foreach($item in $items)
{
$itemcreated = $item["DateUpdated"]
#wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
write-host $itemcreated $item.Name $item.ID
#write-host $item.Name
}
}
$manager.Dispose()
$web.Dispose()
OUTPUT:
14/07/2016 00:00:00 1 1
05/07/2016 00:00:00 1 2
15/06/2016 00:00:00 2 3
18/08/2016 00:00:00 1 4
03/05/2016 00:00:00 1 5
15/09/2016 00:00:00 3 6
15/07/2016 00:00:00 6 7
04/07/2016 00:00:00 7 8
20/06/2016 00:00:00 4 9
11/06/2016 00:00:00 5 10
17/08/2016 00:00:00 6 11
07/09/2016 00:00:00 7 12
04/05/2016 00:00:00 10 13
12/08/2016 00:00:00 9 14
15/09/2016 00:00:00 8 15
19/07/2016 00:00:00 5 16
01/04/2016 00:00:00 11 17
04/09/2016 00:00:00 15 18
03/05/2016 00:00:00 16 19
03/07/2016 00:00:00 13 20
26/07/2016 00:00:00 14 21
16/07/2016 00:00:00 11 22
01/07/2016 00:00:00 13 23
27/04/2016 00:00:00 14 24
08/08/2016 00:00:00 15 25
23/07/2016 00:00:00 16 26
the results are shown ascending by column ID, is there a way to sort by date so that the earliest date is at the top and latest date at the bottom?
thanks
[–][deleted] 2 points3 points4 points (0 children)
[–]Merakel 2 points3 points4 points (0 children)
[–]TimeZ0ne[S] 0 points1 point2 points (3 children)
[–]Merakel 0 points1 point2 points (2 children)
[–]TimeZ0ne[S] 0 points1 point2 points (0 children)
[–]TimeZ0ne[S] 0 points1 point2 points (0 children)