Using Powershell, I have to get the total size of all attached files on all list items for a generic list. I tried using the function below but this displays the total length of names for the attached files.
function GetListSize($List)
{
[long]$listSize = 0
foreach ($listItem in $List.Items)
{
$listItemAttachments = $listItem.Attachments
foreach($file in $listItemAttachments)
{
$listSize += $file.Length
}
}
$totalInMb = ($listSize/1024)/1024
$totalInMb = "{0:N2}" -f $totalInMb
return $totalInMb
}
I can do this using C# code (How to get size of SharePoint 2010 list item attachment?). How can I do this using Powershell?