I am working on a powershell script to start the workflow on items in a list,
$url = “https://xxxxx.sharepoint.com/sites/xxxxxxxxxxxx”
$username = "username"
$password = Read-Host -Prompt "Enter password" -AsSecureString
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url);
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$clientContext.Credentials = $credentials
$list = $clientContext.Web.Lists.GetByTitle("contracten");
$query = New-Object Microsoft.SharePoint.Client.CamlQuery;
$query.ViewXml = "<OrderBy><FieldRef Name='Actie_x0020_datum' Ascending='False' /></OrderBy>"
$listItems = $list.GetItems($query);
$clientContext.Load($listItems);
$clientContext.ExecuteQuery();
$tasks =@();
foreach ($listItem in $listItems)
{
Write-Host $ListItem.Id
}
In the for loop, i let it print the Id's of the list item so I can see the order of the items. Whatever I try, it always returns the items in the same order, and nog ordering them by the field that I am trying to sort on.
Can anyone see if there is something that I do wrong? I'm struggling with this for days now.