使用 PowerShell v2.0 获取 SharePoint 2007 中所有列表项上附加文件的总大小
使用 Powershell,我必须获取通用列表的所有列表项上所有附加文件的总大小。我尝试使用下面的函数,但这将显示附加文件名称的总长度。
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
}
我可以使用 C# (http://mykiavash.wordpress.com/2011/05/02/how-to-get-size-of-sharepoint-2010-list-item-attachment/) 代码执行此操作,但使用 PowerShell 没有 ideea脚本。你有什么想法吗?
Using Powershell I have to get the total size of all attached files on all list items for a generic list. 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. Do you have any ideea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,omlin 帮我解决了这个问题。请参阅:
https://sharepoint.stackexchange.com/questions/12652/get-total-size-of-attached-files-on-all-list-items-in-sharepoint-2007with-powersh
检查大小使用这个界面很好: http:// /msmvps.com/blogs/shane/archive/2008/06/20/list-size-reporting.aspx
ok, omlin helped me to solve this. pls see :
https://sharepoint.stackexchange.com/questions/12652/get-total-size-of-attached-files-on-all-list-items-in-sharepoint-2007with-powersh
To check the size using the interface this is nice : http://msmvps.com/blogs/shane/archive/2008/06/20/list-size-reporting.aspx