0

I have this code:

$List = $Context.web.Lists.GetByTitle("MyList")
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$ListItems = $List.GetItems($Query)
$context.Load($ListItems)
$context.ExecuteQuery() 
$ListItemCollection = @() 
$ListItems | foreach {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name "Datum" -value $_["Datum"].ToLocalTime().ToString("dd-MM-yyyy");
$ExportItem | Add-Member -MemberType NoteProperty -name "00:00 - 07:59" -value $_["00:00 - 07:59"]
$ExportItem | Add-Member -MemberType NoteProperty -name "08:00 - 16:59" -value $_["08:00 - 16:59"]
$ExportItem | Add-Member -MemberType NoteProperty -name "17:00 - 23:59" -value $_["17:00 - 23:59"]
$ExportItem | Add-Member -MemberType NoteProperty -name "Opmerkingen" -value $_["Opmerkingen"]
$ListItemCollection += $ExportItem
}
$ListItemCollection | epcsv "c:\Temp\MyList" -NoT

I found this but I don't know how to implement it:

#Get the Target List
$list = $web.Lists["test"]
#Get the View
$view = $list.Views["Today"] 

#Get All items from the view
$items = $list.GetItems($view)

Gr. P

1
  • But what you find it was for OnPrem SP on Online. i will try find the same for spo. Jan 23, 2019 at 8:26

1 Answer 1

0

Use:

$list = $Context.web.Lists.GetByTitle("MyList")
$view = $list.views.GetByTitle("CustomView")  
$context.load($view)  
$context.executeQuery()  
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$Query.ViewXml = "<View><Query>" + $view.ViewQuery +"</Query></View>"
$ListItems = $List.GetItems($Query)
$context.Load($ListItems)
$context.ExecuteQuery()
2
  • After testing it. It doesn't work.
    – user78519
    Jan 23, 2019 at 9:02
  • With your new code it works :) :) ;) Thank you very much. Gr. P
    – user78519
    Jan 23, 2019 at 9:04

Your Answer

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