2

I've run into an issue whereby running the below code will only return the items within the current page of a view. I.e. If I have 30 items in my view, but 60 total, I will only be returned 30 items.

$web = Get-SPWeb $($webUrl);
$list = $web.Lists.get_Item($listName);
$view = $list.Views[$viewName];
$items = $list.GetItems($view);

Question: Is there a way to query the view and get all items, regardless of any paging?

1 Answer 1

3

Yes, there is a way. You need to use an SPQuery object (based on your SPView). Use the following PowerShell commands:

$web = Get-SPWeb $($webUrl);
$list = $web.Lists.get_Item($listName);
$view = $list.Views[$viewName];
$spQuery = New-Object Microsoft.SharePoint.SPQuery($view)
$spQuery.RowLimit = 0
$items = $list.GetItems($spQuery);
0

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.