使用Powershell我必須獲取通用列表的所有列表項上所有附加文件的總大小。我嘗試使用下面的函數,但這會顯示附加文件的名稱總長度。使用PowerShell v2.0獲取SharePoint 2007中所有列表項上的附加文件總大小
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。你有什麼想法嗎?
上面的代碼實際上是得到一個列表的大小。 '$ file.length'給出的文件「大小」不是文件名的長度。 – ravikanth 2011-05-13 08:16:40