Created
September 19, 2019 19:16
-
-
Save mirontoli/5944191fd07d0286c32a54465052c2cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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