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?

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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