Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Created September 19, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/5944191fd07d0286c32a54465052c2cf to your computer and use it in GitHub Desktop.
Save mirontoli/5944191fd07d0286c32a54465052c2cf to your computer and use it in GitHub Desktop.
#This script gets the totals from a list view
Connect-PnPOnline https://siteurl
$context = Get-PnPContext
$list = $context.Web.Lists.GetByTitle("mylist")
$view =$list.Views.GetByTitle("MyViewWithTotals")
$context.Load($view)
$context.ExecuteQuery()
# we only need one item, not more
$viewxml = $view.ListViewXml -replace '<RowLimit Paged="TRUE">\d*</RowLimit>','<RowLimit>1</RowLimit>'
$result = $list.RenderListData($viewxml)
$context.ExecuteQuery()
$obj = ConvertFrom-Json $result.Value
$row = $obj.Row[0]
# Now use your values
$count = $row.'LinkTitle.COUNT'
$sizeSum = $row.'size.SUM'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment