简体   繁体   English

使用PowerShell v2.0获取SharePoint 2007中所有列表项上附加文件的总大小

[英]Get total size of attached files on all list items in SharePoint 2007with PowerShell v2.0

Using Powershell I have to get the total size of all attached files on all list items for a generic list. 使用Powershell,我必须获取通用列表的所有列表项上所有附件的总大小。 I tryed to use the function below but this will display the total length of names for the attached files. 我尝试使用下面的功能,但这将显示附件的名称总长度。

function GetListSize($List, $Web)
{
    [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# (http://mykiavash.wordpress.com/2011/05/02/how-to-get-size-of-sharepoint-2010-list-item-attachment/) code but no ideea using PowerShell script. 我可以使用c#(http://mykiavash.wordpress.com/2011/05/02/how-to-get-size-of-sharepoint-2010-list-item-attachment/)代码来执行此操作,但不能使用PowerShell进行操作脚本。 Do you have any ideea ? 你有什么想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM