Sometimes you just want to know how big are your attachments within a SharePoint list? Here you get a simple PowerShell Script to get these information
$file.Length
Sample list called “MySampleList” and as you can see there are more than one attachments added to file “Mein File 1”
Use the following code:
[sourcecode language=”powershell”]
#Version 1.0
< #
.DESCRIPTION
.NOTES
File Name : GetListAttachmentInformation.ps1
Author : Dennis de Vries (ddv@inconsult-online.de)
Copyright 2014 : INCONSULT Volker Schäfer / Dennis de Vries
.LINK
..::ILikeSharePoint::..
www.ilikesharepoint.de
#>
$web = Get-SPWeb -Identity http://isv82/sites/ddv/
$list = $web.Lists[“MySampleList”]
foreach ($item in $list.Items)
{
$attachmentCollection = $item.Attachments
$folder = $web.GetFolder($attachmentCollection.UrlPrefix);
foreach ($file in $folder.Files)
{
Write-Host $item.Title
Write-Host $file.Name
Write-Host $file.Length
}
}
[/sourcecode]
Within the output you will get the File Size:
..::ILikeSharePoint::..
Leave a Reply
You must be logged in to post a comment.